Found 6702 Articles for Database

Evaluate one of more values from a MongoDB collection with documents

AmitDiwan
Updated on 27-Mar-2020 06:51:19

76 Views

To evaluate one or more values, use $or along with find(). Let us create a collection with documents −> db.demo174.insertOne({"StudentName":"Chris", "CountryName":"US"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5e383c709e4f06af551997e5") } > db.demo174.insertOne({"StudentName":"David", "CountryName":"UK"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5e383c779e4f06af551997e6") } > db.demo174.insertOne({"StudentName":"Bob", "CountryName":"AUS"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5e383c7e9e4f06af551997e7") }Display all documents from a collection with the help of find() method −> db.demo174.find();This will produce the following output −{ "_id" : ObjectId("5e383c709e4f06af551997e5"), "StudentName" : "Chris", "CountryName" : "US" } { "_id" : ObjectId("5e383c779e4f06af551997e6"), "StudentName" : "David", "CountryName" : "UK" } { "_id" : ... Read More

Limit number of values in a field with MongoDB?

AmitDiwan
Updated on 27-Mar-2020 06:49:39

128 Views

To limit the number of values in a field, use MongoDB $slice. Let us create a collection with documents −> db.demo173.insertOne({"ListOfValues":[10, 40, 100, 560, 700, 900]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5e383a4f9e4f06af551997e4") }Display all documents from a collection with the help of find() method −> db.demo173.find().pretty();This will produce the following output −{    "_id" : ObjectId("5e383a4f9e4f06af551997e4"),    "ListOfValues" : [10, 40, 100, 560, 700, 900 ] }Following is the query to limit number of values in a field using MongoDB −> db.demo173.find({}, { "ListOfValues": { "$slice": -2 } } );This will produce the following output −{ "_id" ... Read More

Find a value in lowercase from a MongoDB collection with documents

AmitDiwan
Updated on 27-Mar-2020 06:45:06

3K+ Views

To find a value in lowercase, use the toLowerCase() method in MongoDB. Use the method in find() to find the value in lowercase.Let us create a collection with documents −> db.demo172.insertOne({"SubjectName":"MySQL"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5e3838ce9e4f06af551997e1") } > db.demo172.insertOne({"SubjectName":"mongodb"}); {     "acknowledged" : true,    "insertedId" : ObjectId("5e3838d69e4f06af551997e2") } > db.demo172.insertOne({"SubjectName":"MongoDB"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5e3838db9e4f06af551997e3") }Display all documents from a collection with the help of find() method −> db.demo172.find();This will produce the following output −{ "_id" : ObjectId("5e3838ce9e4f06af551997e1"), "SubjectName" : "MySQL" } { "_id" : ObjectId("5e3838d69e4f06af551997e2"), "SubjectName" : "mongodb" } ... Read More

How to re-map the fields of a MongoDB collection?

AmitDiwan
Updated on 27-Mar-2020 06:40:03

209 Views

To re-map the fields of a MongoDB collection, use update() along with $rename. Let us first create a collection with documents −> db.demo171.insertOne( { "Name": "Chris", "Details": { "SubjectName": "MySQL", "CountryName": "US" } } ); {    "acknowledged" : true,    "insertedId" : ObjectId("5e3837 399e4f06af551997e0") }Display all documents from a collection with the help of find() method −> db.demo171.find();This will produce the following output −{ "_id" : ObjectId("5e3837399e4f06af551997e0"), "Name" : "Chris", "Details" : { "SubjectName" : "MySQL", "CountryName" : "US" } }Following is the query to re-map the fields of a MongoDB collection −> db.demo171.update({}, { $rename : { 'Name' ... Read More

Mean and Mode in SQL Server

Narendra Kumar
Updated on 10-Feb-2020 10:08:33

1K+ Views

Problem statementMean is the average of the given data set calculated by dividing the total sum by the number of values in the data set.Mode of a data set is the value that appears most frequently in a series of dataIf our dataset is {1, 2, 3, 4} then mean value is − (1 + 2 + 3 + 4) / 4 = 2.5If our dataset is {1, 2, 3, 4, 1, 1, 1, 1} then mode value is − 1 as it appears 5 times.ExampleFirst, create a table −CREATE TABLE NUMBERS (    value INT )Insert data into the ... Read More

MySqldb Connection in Python

Pradeep Elance
Updated on 04-Feb-2020 06:44:47

221 Views

Mysql is one of the most widely used open source Dbs. Python provides ways to connect to this DB and use the DB to store and retrive the data from it.Install pymysqlDepending on the python environment you are using, pymysql package can be installed using one of the following methods.# From python console pip install pymysql #Using Anaconda conda install -c anaconda pymysql # Add modules using any python IDE pymysqlConnecting to MySqlNow we can connect to the Mysql environment using the following code. After connecting we are finding out the version of the DB.Exampleimport pymysql # Open database connection ... Read More

Primary key Vs Unique key

sudhir sharma
Updated on 03-Feb-2020 11:11:25

11K+ Views

Primary KeyPrimary Key is a column that is used to uniquely identify each tuple of the table.It is used to add integrity constraints to the table. Only one primary key is allowed to be used in a table. Duplicate and NULL (empty) values are not valid in the case of the primary key. Primary keys can be used as foreign keys for other tables too.Let’s take an example, We have a table name employee which stores data of employees of a company. The below table shows the contents of the table.Emp_idNamePh_No.PositionSalaryEmp_id here is primary key of the table. As the ... Read More

How IoT impacts Big Data

Samual Sam
Updated on 28-Jan-2020 10:38:05

369 Views

When it comes to two of the most talked about technologies in present times, Big Data and Internet of Things (IoT) are perhaps right at the helm. And over the last few years, Big Data has made progress in numerous domains. And although Internet of Things happens to be different, it is massively linked to Big Data.What is Big Data?Big Data is essentially a large amount of data that is in complex form. Specifically, it also refers to the use of predictive analysis and methods that allows extraction of valuable information from such data. This allows better decision making, reduction ... Read More

Difference between Data Warehouse and Operational Database

Kiran Kumar Panigrahi
Updated on 11-Jan-2023 14:48:38

8K+ Views

A data warehouse is a repository for structured, filtered data that has already been processed for a specific purpose. It collects the data from multiple sources and transforms the data using ETL process, then loads it to the Data Warehouse for business purpose. An operational database, on the other hand, is a database where the data changes frequently. They are mainly designed for high volume of data transaction. They are the source database for the data warehouse. Operational databases are used for recording online transactions and maintaining integrity in multi-access environments. Read this article to learn more about data warehouses ... Read More

Difference between Data lake and Data warehouse

Kiran Kumar Panigrahi
Updated on 21-Feb-2023 12:44:04

672 Views

Data Lake and Data Warehouse both are used for storing big data. A Data Lake is a very big storage repository which is used to store raw unstructured data, machine to machine, logs flowing through in real-time. The purpose of the stored data is not defined in a data lake. They are stored for future analysis of the data. A data warehouse is a repository for structured, filtered data that has already been processed for a specific purpose. A Data warehouse collects the data from multiple sources and transforms the data using ETL process, then loads it to the Data ... Read More

Advertisements