Found 6702 Articles for Database

Get the aggregated result and find the count of repeated values in different MongoDBdocuments

AmitDiwan
Updated on 11-May-2020 09:11:28

114 Views

To get the count of repeated values in different documents, use aggregate(). Let us create a collection with documents −> db.demo452.insertOne({"StudentName":"John", "StudentAge":21});{    "acknowledged" : true,    "insertedId" : ObjectId("5e7b7e3371f552a0ebb0a6f3") } > db.demo452.insertOne({"StudentName":"John", "StudentAge":22});{    "acknowledged" : true,    "insertedId" : ObjectId("5e7b7e3671f552a0ebb0a6f4") } > db.demo452.insertOne({"StudentName":"John", "StudentAge":23});{    "acknowledged" : true,    "insertedId" : ObjectId("5e7b7e3971f552a0ebb0a6f5") } > db.demo452.insertOne({"StudentName":"David", "StudentAge":24});{    "acknowledged" : true,    "insertedId" : ObjectId("5e7b7e4371f552a0ebb0a6f6") } > db.demo452.insertOne({"StudentName":"David", "StudentAge":25});{    "acknowledged" : true,    "insertedId" : ObjectId("5e7b7e4571f552a0ebb0a6f7") }Display all documents from a collection with the help of find() method −> db.demo452.find();This will produce the following output −{ "_id" : ... Read More

MongoDB aggregate to get the Mean daily average count of recorded documents in a collection?

AmitDiwan
Updated on 11-May-2020 10:07:14

744 Views

To get the mean daily average count of recorded documents, use aggregate(). Within that, use $project and $group.Let us create a collection with documents −Example> db.demo451.insertOne({ ... DueDate:new ISODate("2020-03-15T10:50:35.000Z"), ... Value: 10 ... } ... ); {    "acknowledged" : true,    "insertedId" : ObjectId("5e7b5c5d71f552a0ebb0a6e9") } > db.demo451.insertOne({ ... DueDate:new ISODate("2020-03-14T10:50:35.000Z"), ... Value: 10 ... } ... ); {    "acknowledged" : true,    "insertedId" : ObjectId("5e7b5c5d71f552a0ebb0a6ea") } > db.demo451.insertOne({ ... DueDate:new ISODate("2020-03-13T10:50:35.000Z"), ... Value: 10 ... } ... ); {    "acknowledged" : true,    "insertedId" : ObjectId("5e7b5c5d71f552a0ebb0a6eb") }Display all documents from a collection with the help of find() ... Read More

How to reach subdata in MongoDB and display a particular document?

AmitDiwan
Updated on 11-May-2020 09:02:59

115 Views

In order to reach subdata, you need to use key in MongoDB. Let us create a collection with documents −>db.demo450.insertOne({"Information":{"StudentDetails":{"StudentName":"Chris", "StudentAge":21}}}); {    "acknowledged" : true,    "insertedId" : ObjectId("5e7b590e71f552a0ebb0a6e6") } >db.demo450.insertOne({"Information":{"StudentDetails":{"StudentName":"David", "StudentAge":23}}});{    "acknowledged" : true,    "insertedId" : ObjectId("5e7b591a71f552a0ebb0a6e7") } >db.demo450.insertOne({"Information":{"StudentDetails":{"StudentName":"Mike", "StudentAge":22}}});{    "acknowledged" : true,    "insertedId" : ObjectId("5e7b592271f552a0ebb0a6e8") }Display all documents from a collection with the help of find() method −> db.demo450.find();This will produce the following output −{ "_id" : ObjectId("5e7b590e71f552a0ebb0a6e6"), "Information" : { "StudentDetails" : { "StudentName" : "Chris", "StudentAge" : 21 } } } { "_id" : ObjectId("5e7b591a71f552a0ebb0a6e7"), "Information" : { "StudentDetails" : { ... Read More

How to insert an item to an array that is inside an object in MongoDB?

AmitDiwan
Updated on 11-May-2020 09:02:05

762 Views

To insert an item to an already created array inside an object, use MongoDB $push. Let us create a collection with documents −> db.demo449.insertOne( ... { ...    details1: { ...       details2: [{ ...          _id:new ObjectId(), ...             Name:"Chris" ...       }], ...       details3: [{ ...          _id:new ObjectId(), ...          Name:"David" ...       }] ...    } ... } ... ); {    "acknowledged" : true,    "insertedId" : ObjectId("5e7a40e971f552a0ebb0a6e3") }Display all documents from ... Read More

What is the difference between deleteOne() and findOneAndDelete() operation in MongoDB?

AmitDiwan
Updated on 11-May-2020 08:59:12

2K+ Views

The findOneAndDelete() deletes single documents from the collection on the basis of a filter and sort criteria as well as it returns the deleted document.The deleteOne() removes single document from the collection.Let us see an example and create a collection with documents −> db.demo448.insertOne({"Name":"Chris", "Age":21});{    "acknowledged" : true,    "insertedId" : ObjectId("5e7a291cbbc41e36cc3caeca") } > db.demo448.insertOne({"Name":"David", "Age":23});{    "acknowledged" : true,    "insertedId" : ObjectId("5e7a2926bbc41e36cc3caecb") } > db.demo448.insertOne({"Name":"Bob", "Age":22});{    "acknowledged" : true,    "insertedId" : ObjectId("5e7a2930bbc41e36cc3caecc") }Display all documents from a collection with the help of find() method −> db.demo448.find();This will produce the following output −{ "_id" : ObjectId("5e7a291cbbc41e36cc3caeca"), ... Read More

Difference between Inverted Index and Forward Index

Mahesh Parahar
Updated on 15-Apr-2020 08:22:52

1K+ Views

Inverted Index and Forward Index are data structures used to search text in a document or set of documents.Inverted IndexInverted Index stores the words as index and document name(s) as mapped reference(s).Forward IndexForward Index stores the document name as index and word(s) as mapped reference(s).The following are some of the important differences between the Inverted Index and Forward Index.Sr. No.KeyInverted IndexForward Index1Mapping PatternInverted Index stores the words as index and document name(s) as mapped reference(s).Forward Index stores the document name as index and word(s) as mapped reference(s).2Index Building ProcessScan the document, prepare a list of unique words.Prepare a list of ... Read More

Difference between Data Scientist, Data Engineer, Data Analyst

Kiran Kumar Panigrahi
Updated on 11-Jan-2023 14:46:13

636 Views

Data scientists, data engineers, and data analysts are all professionals who work with data in some way. However, they have different roles and responsibilities. Read this article to find out more the job profiles of data scientists, data engineers, and data analysts and how you can distinguish among them. Who is a Data Scientist? A Data Scientist is one who analyses and interprets complex data in digital form. Data scientists are responsible for extracting insights and knowledge from data. They use a variety of techniques, including machine learning, to analyze data and communicate their findings to stakeholders. There are several ... Read More

Difference between Static SQL and Dynamic SQL

Mahesh Parahar
Updated on 16-May-2020 14:18:51

23K+ Views

Static SQLStatic SQL refers to those SQL statements which are fixed and can be hard coded into the application. As static sqls are fixed queries, these statements can be analysed and optimized and do not require any specific handling for security purpose.Dynamic SQLDynamic SQL refers to those SQL statements which are generated dynamically based on user's input and run in the application. Dynamic Sqls helps to develop general and flexible applications. Dynamic SQL may need more permissions and security handling and a malicious user can create dangerous code as well.Following are some of the important differences between Static Routing and ... Read More

MySQL query to remove numbers after hyphen in a VARCHAR string with numbers

AmitDiwan
Updated on 07-Apr-2020 11:54:11

402 Views

For this, use SUBSTRING_INDEX(). Let us first create a table −mysql> create table DemoTable2040    -> (    -> StudentCode varchar(20)    -> ); Query OK, 0 rows affected (0.85 sec)Insert some records in the table using insert command −mysql> insert into DemoTable2040 values('John-232'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable2040 values('Carol-901'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable2040 values('David-987'); Query OK, 1 row affected (0.21 sec)Display all records from the table using select statement −mysql> select *from DemoTable2040;This will produce the following output −+-------------+ | StudentCode | +-------------+ | ... Read More

Displaying only a list of records in ASC order with MySQL

AmitDiwan
Updated on 07-Apr-2020 11:52:28

100 Views

To display a list of records in a specific order, you need to set conditions and use ORDER BY. For this, use ORDER BY CASE statement. Let us first create a table −mysql> create table DemoTable2039    -> (    -> Name varchar(20)    -> ); Query OK, 0 rows affected (0.62 sec)Insert some records in the table using insert command −mysql> insert into DemoTable2039 values('John Doe'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable2039 values('John Smith'); Query OK, 1 row affected (0.08 sec) mysql> insert into DemoTable2039 values('Chris Brown'); Query OK, 1 row affected ... Read More

Advertisements