Skip to content

Instantly share code, notes, and snippets.

@Kishimoto96
Created April 27, 2023 14:36
Show Gist options
  • Save Kishimoto96/1dcb8bddee9f84b77c7ef4d1bb5cd2fa to your computer and use it in GitHub Desktop.
Save Kishimoto96/1dcb8bddee9f84b77c7ef4d1bb5cd2fa to your computer and use it in GitHub Desktop.

Discussion about SQL and NoSQL:

  1. What is NoSQL?
  2. What is the difference between SQL and NoSQL databases, and when should you use one over the other?
  3. How do the data structures of SQL and NoSQL databases differ?
  4. What is MongoDB? and why we call it a document-oriented database?
  5. What are the most important MongoDB commands? explain two of them.
@idincer944
Copy link

members: @idincer944, Atakan Serbes, Iroda Yılmaz, Tareq Harh

  1. NoSQL (Not Only SQL) is a category of databases that do not use the traditional relational model for storing and retrieving data. Instead, NoSQL databases use a variety of different data models and storage techniques that are designed to be more flexible, scalable, and efficient than relational databases in certain use cases.

  2. SQL databases are vertically scalable, which means that they require more powerful hardware as the data size and complexity grow. NoSQL databases are horizontally scalable, which means that they can scale out by adding more nodes to the cluster to handle increased traffic and data volume. If your data has a well-defined structure and requires strict data consistency, then a SQL database may be a better fit. If you need to store and process large volumes of unstructured or semi-structured data, with high levels of scalability and performance, then a NoSQL database may be a better fit.

  3. SQL databases use a structured data model based on tables, where each table consists of rows and columns. Each row represents a single record or instance of the data, while each column represents an attribute or property of the data. The relationships between tables are established through primary and foreign keys, which define the links between related data.

In contrast, NoSQL databases use a variety of different data models, such as document-oriented, key-value, column-family, and graph-oriented models. These models are designed to handle large volumes of unstructured or semi-structured data, with greater flexibility and scalability than SQL databases.

  1. MongoDB is a popular NoSQL document-oriented database. It is designed for storing and managing large volumes of unstructured or semi-structured data, such as JSON or BSON documents. A record in MongoDB is a document, which is a data structure composed of field and value pairs. MongoDB documents are similar to JSON objects. The values of fields may include other documents, arrays, and arrays of documents.

  2. delete - Deletes one or more documents.
    find - Selects documents in a collection or a view.
    findAndModify - Returns and modifies a single document.
    getMore - Returns batches of documents currently pointed to by the cursor.
    insert - Inserts one or more documents.
    resetError - Removed in MongoDB 5.0. Resets the last error status.
    update - Updates one or more documents.

@Eng-NUREDDIN
Copy link

Eng-NUREDDIN commented Apr 27, 2023

@NourEddinHamouda @muhammedhasann @handedemirbay @0Rawan
1- NoSQL (short for “not only SQL”) is a type of database management system that is designed to handle and store large volumes of unstructured and semi-structured data. NoSQL databases are non-tabular and store data differently than relational tables. The main types of NoSQL databases are document, key-value, wide-column, and graph. They provide flexible schemas and scale easily with large amounts of data and high user loads.

2-
image
SQL databases are relational, and NoSQL databases are non-relational.
SQL databases use structured query language (SQL) and have a predefined schema. NoSQL databases have dynamic schemas for unstructured data.
SQL databases are vertically scalable, while NoSQL databases are horizontally scalable.
SQL databases are table-based, while NoSQL databases are document, key-value, graph, or wide-column stores.
SQL databases are better for multi-row transactions, while NoSQL is better for unstructured data like documents or JSON.

3- SQL databases are based on the relational data model, which uses a structured schema to define the tables and relationships between them.
On the other hand, NoSQL databases use different data models, such as document, key-value, column-family, or graph-based, to store and organize data. In document-based NoSQL databases, data is stored as documents.

4- MongoDB is a popular NoSQL database system that is designed to store and manage large amounts of data in a highly scalable, distributed, and high-performance way. It is an open-source, document-oriented database that uses JSON-like documents to store data.
MongoDB is called a document-oriented database because it stores data in the form of documents, which are JSON-like objects that contain key-value pairs. Each document can have its own unique structure and schema, which makes it more flexible than traditional relational databases. Documents can be nested, meaning that one document can contain another document as a value, allowing for more complex and hierarchical data structures.

5-use - This command is used to select the database you want to work with.�db.collection.insertOne() - This command is used to insert a document into a collection.�db.collection.find() - This command is used to find documents in a collection.�db.collection.updateOne() - This command is used to update a document in a collection.�db.collection.deleteOne() - This command is used to delete a document from a collection.
image
db.collection.insertOne()�The insertOne() command is used to insert a document into a collection. For example, to insert a document into the collection called users, you would use the following command:
db.users.insertOne({� name: "John Doe",� email: "johndoe@example.com"�})

@omikay
Copy link

omikay commented Apr 27, 2023

Omid Kayhani | Bedreddin Naser | Younes Nouzehi | Mohammad Almohammad

  1. NoSQL is a type of non-relational databases that is used for their scalability and performance. Such data include key-valued ones such as objects, JSON, etc.
  2. SQL databases are data that comply with the same data model as in tables, but NoSQL databases might follow multiple data models like key-value data, graphs, documents, etc., in one database. Also, the language for SQL databases is SQL, while NoSQL databases do not follow a specific programming language. We use NoSQL when we have large amounts of data that are also based on various data models, and we want to have high performance. The most used industry NoSQL DBMS include MongoDB and Cassandra.
  3. SQL is like a table with the same set of attributes for the every data point, but NoSQL is a mix of different data structures (models).
  4. MongoDB is a DBMS for NoSQL data. MongoDB is a document-oriented database, which means that it stores data in documents. Documents are like JSON objects, and they can contain a variety of data types, including strings, numbers, arrays, and objects.
  5. db.collection.find():
    This command is used to retrieve documents from a collection in MongoDB. It allows you to query for documents based on specified criteria, such as filtering by fields or sorting the results.

db.collection.updateOne():
This command is used to update a single document in a collection in MongoDB. It allows you to modify the existing data or add new data to a document.

some more important ones:
insert()
insertOne()
update()
remove()
deleteOne()
createIndex()
getIndexes()
count()
distinct()
aggregate()
createCollection()

@AhmedAlo1993
Copy link

@Özlem KELEŞ @Ahmed RASHEED @harith RIYADH @berra MAHMUT

  1. NoSQL databases are non-tabular databases and store data differently than relational tables. NoSQL databases come in a variety of types based on their data model. The main types are document, key-value, wide-column, and graph. They provide flexible schemas and scale easily with large amounts of data and high user loads.

  2. The main difference between SQL and NoSQL databases is their data model and the way they store and retrieve data. SQL databases are relational and use a structured query language (SQL) to access and manipulate data stored in tables with fixed schemas, while NoSQL databases are non-relational and use various data models to store and retrieve data, such as key-value pairs, documents, or graphs.

  3. SQL databases use tables with fixed schema to store data, and a structured query language (SQL) to access and manipulate data. NoSQL databases use a variety of data structures depending on the specific data model used, including key-value stores, document stores, column-family stores, and graph databases. NoSQL databases are designed to be more flexible and scalable than SQL databases, but may come at the cost of reduced data consistency and integrity.

  4. MongoDB is a popular NoSQL database management system that is used for storing and managing large volumes of unstructured or semi-structured data. Unlike traditional relational databases, MongoDB is a document-oriented database, meaning that it stores data in flexible, JSON-like documents, rather than in rigid tables with fixed schemas.

  5. db.collection.find(): This command is used to retrieve data from a specific collection in the database.
    find- It accepts a query object as a parameter
    db.collection.insertOne(): This command is used to insert a single document into a specific collection in the database.
    Other important MongoDB commands include
    db.collection.updateOne(), db.collection.deleteOne(), db.collection.aggregate(), and
    db.collection.createIndex()

@radmanlo
Copy link

Members: Radman, Nur Abunamus, Fatima ALI, Guled Khadar, Nezir Aydin

  1. NoSQL, also referred to as “not only SQL”, “non-SQL”, is an approach to database design that enables the storage and querying of data outside the traditional structures found in relational databases. While it can still store data found within relational database management systems (RDBMS), it just stores it differently compared to an RDBMS. The decision to use a relational database versus a non-relational database is largely contextual, and it varies depending on the use case.
  2. SQL databases are relational, and NoSQL databases are non-relational. SQL databases use structured query language (SQL) and have a predefined schema. NoSQL databases have dynamic schemas for unstructured data. SQL databases are vertically scalable, while NoSQL databases are horizontally scalable. Non-relational databases are most suited to handling large volumes of data and/or unstructured data. They're extremely popular in the world of big data because writes are fast.
  3. SQL databases are best used for structured data, NoSQL databases are suitable for structured, semi-structured, and unstructured data. SQL databases are table-based, while NoSQL databases are document, key-value, graph, or wide-column stores. SQL databases are better for multi-row transactions, while NoSQL is better for unstructured data like documents or JSON.
  4. MongoDB is the most popular NoSQL database, and it is considered a document database. MongoDB is generally considered very straightforward to use, because working with it is very similar to working with JSON, which many web developers are familiar with. MongoDB stores data in JSON-like structures referred to as documents.
  5. Query and Write Operation Commands: delete,find ,update / Aggregation Commands: count / Query Plan Cache Commands: planCacheClear, planCacheClearFilters.

@Mustapha909
Copy link

Fatma Zehra Aydin, Rayan Alrouh, @sheidanouri, @Mustapha909

1-NoSQL can be defined as an approach to database designing, which holds a vast diversity of data such as key-value, multimedia, document, columnar, graph formats, external files, etc. NoSQL is purposefully developed for handling specific data models having flexible schemas to build modern applications.
NoSQL is famous for its high functionality, ease of development with a performance at scale. Because of such diverse data handling features, NoSQL is called a non-relational database. It does not follow the rules of Relational Database Management Systems (RDBMS), and hence does not use traditional SQL statements to query your data. Some famous examples are MongoDB, Neo4J, HyperGraphDB, etc.

2- The main difference between SQL and NoSQL databases is in their data modeling approach, with SQL databases using a structured, tabular data model and NoSQL databases using a more flexible, non-relational data model. SQL databases are ideal for applications that require complex querying and strict data consistency, while NoSQL databases are better suited for applications with rapidly changing data requirements, high data volume, and data that is unstructured or semi-structured. Choosing between SQL and NoSQL databases depends on the specific needs of the application and the trade-offs between consistency, scalability, and performance.

3- The five critical differences between SQL and NoSQL are:
SQL databases are relational, and NoSQL databases are non-relational.
SQL databases use structured query language (SQL) and have a predefined schema. NoSQL databases have dynamic schemas for unstructured data.
SQL databases are vertically scalable, while NoSQL databases are horizontally scalable.
SQL databases are table-based, while NoSQL databases are document, key-value, graph, or wide-column stores.
SQL databases are better for multi-row transactions, while NoSQL is better for unstructured data like documents or JSON

4- MongoDB is a popular open-source NoSQL document-oriented database that stores and manages data in flexible, JSON-like documents instead of tables with fixed schemas used in traditional relational databases. Each document can contain different types and amounts of data, and can be nested to form complex data structures. MongoDB uses a flexible data model that allows data to be stored in a way that reflects the structure of the application's objects or documents, making it easier and more natural to work with data. This is why MongoDB is called a document-oriented database, as it emphasizes storing data in documents rather than in tables with structured relationships.

5- 5. db.collection.find(): This command is used to retrieve documents from a collection in MongoDB. It takes an optional query parameter that can be used to filter the results based on specific criteria. For example, the command db.users.find({ age: { $gt: 25 } }) would retrieve all documents from the "users" collection where the "age" field is greater than 25. The find() command can also be used to specify which fields should be included or excluded from the results, and to sort the results based on specific criteria.

db.collection.updateOne(): This command is used to update a single document in a collection in MongoDB. It takes two parameters: a filter that identifies which document to update, and an update operation that specifies the changes to be made to the document. For example, the command db.users.updateOne({ name: "Alice" }, { $set: { age: 30 } }) would update the "age" field of the document in the "users" collection where the "name" field is "Alice" to be 30. The updateOne() command can also be used

@Ahmed
Copy link

Ahmed commented Apr 27, 2023 via email

@AmmarAlmuain
Copy link

@ahmadalashtar @masteroflune @Khaled6120 @ahmad Ramin
1- NoSQL databases (aka "not only SQL") are non-tabular databases and store data differently than relational tables. NoSQL databases come in a variety of types based on their data model. The main types are document, key-value, wide-column, and graph. They provide flexible schemas and scale easily with large amounts of data and high user loads.
2- the main diff is the relationship between the db,When to use SQL databases:

You should use SQL databases when you need to store structured data.
You should use SQL databases when you need to perform complex queries on your data.
You should use SQL databases when you need to ensure the consistency of your data.

When to use NoSQL databases

You should use NoSQL databases when you need to store large amounts of unstructured or semi-structured data.
You should use NoSQL databases when you need to store data that is constantly changing.
You should use NoSQL databases when you need to scale your database quickly.

3- noSQL is stored as document "key:value" pairs
SQL is stored in tables columns and rows
4- MongoDB is a document-oriented NoSQL database used for high volume data storage. Instead of using tables and rows as in the traditional relational databases, MongoDB makes use of collections and documents. Documents consist of key-value pairs which are the basic unit of data in MongoDB.
5- use - This command is used to select a database.
db - This command is used to get the current database.
show collections - This command is used to list all of the collections in the current database.
insertOne() - This command is used to insert a single document into a collection.
find() - This command is used to find documents in a collection.

@abdulrahmanalbakkar
Copy link

abdulrahmanalbakkar commented Apr 27, 2023

  1. Abdulrahman Albakkar 2. Cansu Aysagdic 3. Zakarie Ali 4. Hisham Al-Wattar

Q1.
NoSQL databases (aka "not only SQL") are non-tabular databases and store data differently than relational tables. NoSQL databases come in a variety of types based on their data model. The main types are document, key-value, wide-column, and graph. They provide flexible schemas and scale easily with large amounts of data and high user loads.

Q2.
An SQL, or relational database, is excellent for data processing—creating granular connections between pieces of data. A NoSQL database is great for finding one piece of data quickly and operating on it. There's little to no searching; it just gives you the user data.

Q3.
SQL databases are relational, and NoSQL databases are non-relational.
SQL databases are table-based, while NoSQL databases are document, key-value, graph, or wide-column stores.

Q4.
Instead of storing data in fixed rows and columns, document databases use flexible documents. Document databases are the most popular alternative to tabular, relational databases.
A document is a record in a document database. A document typically stores information about one object and any of its related metadata.
Documents store data in field-value pairs. The values can be a variety of types and structures, including strings, numbers, dates, arrays, or objects. Documents can be stored in formats like JSON, BSON, and XML.

To run a command against the current database, use db.runCommand():
db.runCommand( { } )
To run an administrative command against the admin database, use db.adminCommand():
db.adminCommand( { } )
Show dbs:
displays a list of all databases on the MongoDB server.
db.createCollection(""):
creates a new collection in the current database.

@saidbaradai
Copy link

@nourkrimesh @TasneemAkkad @mohamadAid

1-NoSQL is a type of database that can handle large volumes of unstructured data and does not rely on a fixed schema or SQL for querying and managing data. It's often used in web applications for its scalability, performance, and flexibility.

2-SQL databases are relational databases with a fixed structure that enforce strict data consistency, while NoSQL databases are non-relational databases with a flexible structure that prioritize scalability and speed. The choice between SQL and NoSQL depends on the specific requirements of your application and the type of data you need to store and manage.

  1. SQL databases use a tabular structure with pre-defined columns and rows, while NoSQL databases use a variety of flexible data structures such as key-value, document-based, column-family, and graph-based structures to store data. NoSQL databases can handle unstructured and semi-structured data more efficiently than SQL databases.

  2. MongoDB is a popular, flexible, and scalable database platform that is designed to handle large amounts of unstructured or semi-structured data.
    MongoDB is often referred to as a document-oriented database because it stores information in a document format rather than in tables, rows, or columns as in traditional relational databases.

  3. Some of the most important MongoDB commands are db.collection.find(), db.collection.insertOne(), and db.collection.updateOne().
    db.collection.find() is used to retrieve documents that match a query and project the desired fields. db.collection.insertOne() is used to insert a new document into a collection, and db.collection.updateOne() is used to update a single document in a collection that matches a filter.

@sncey
Copy link

sncey commented Apr 27, 2023

@ilaydanurguzel1 @jimaa-maya @tomiece317 @mustafakraizim98 @MuhammedMustafaAlnaddaf1

1- NoSQL (Not Only SQL) is a type of database management system that does not use the traditional SQL relational database model. Instead, NoSQL databases use a flexible and scalable data model, typically using document-oriented, key-value, graph, or column-family database architectures. NoSQL databases are often used for handling large amounts of unstructured or semi-structured data, which can be challenging to manage in a traditional SQL database.

2- SQL databases use structured tables and predefined schemas to store data, while NoSQL databases use flexible data models that can handle various types of data structures. SQL databases are best for applications that require complex querying and have structured data, while NoSQL databases are ideal for applications that need to handle large volumes of rapidly changing and unstructured data. Ultimately, the choice between SQL and NoSQL databases depends on the specific requirements of the application and the type of data that needs to be stored and retrieved. SQL databases are best used for structured data, NoSQL databases are suitable for structured, semi-structured, and unstructured data.

3- SQL databases use a structured, table-based data model with strict data consistency rules, while NoSQL databases use flexible, non-tabular data models that can handle unstructured or semi-structured data without strict data consistency rules. NoSQL databases typically use documents, key-value pairs, graphs, or column families to store data, and they often have a distributed architecture for scalability and high availability.

4- MongoDB is an open-source document-oriented database that is designed to store a large scale of data and also allows you to work with that data very efficiently. It is categorized under the NoSQL (Not only SQL) database because the storage and retrieval of data in the MongoDB are not in the form of tables. Because it handles information as if it were a structured document.
As opposed to a key-value store where the internals of a document are not visible to the database or accessible. In those cases the record must be consumed by the application for processing. Or a column family where parts of the document are placed into columns for access by the database.
MongoDB on the other hand allows indexing and updates within the JSON document that is stored in the db. So each part of the document is accessible to the database.

5- Two important MongoDB commands are db.collection.find(), which is used to query data from a MongoDB collection based on filter criteria, sorting instructions, and projection fields, and db.collection.insertOne(), which is used to insert a single document into a MongoDB collection with the specified data. db.mycol.help()": If you need help using a collection, then you use this command. Example, db.mycol.help().

@motaz99
Copy link

motaz99 commented Apr 27, 2023

Rasam, Asli, Baraah, Motaz

  1. NoSQL databases are non-relational databases. They have roughly the same characteristics as SQL databases (durable, resilient, persistent, replicated, distributed, and performant) except for the major difference of not enforcing schemas (or enforcing only very loose schemas). These databases provide flexible schemas and scale easily with large amounts of data and high user loads.

  2. SQL uses tables and creates relations between data, NoSQL uses documents and most probably doesn't have relations between data. NoSQL databases is better with the huge applications because it is more flexible and cheap for add new features, it are also good with frequent data changes, SQL is slower but still reliable on huge apps, it has fixed data, it is expensive to grow up.

  3. In SQL they use tables to store data and they create relations between tables, NoSQL databases (aka "not only SQL") are non-tabular databases and store data differently than relational tables. NoSQL databases come in a variety of types based on their data model. The main types are document, key-value, wide-column, and graph.

  4. MongoDB is a popular open-source NoSQL database that is designed to store and manage unstructured and semi-structured data. It is a document-oriented database that stores data in flexible and scalable JSON-like documents, which are known as BSON (Binary JSON) documents. MongoDB a document-oriented database because it focuses on storing and managing data as self-contained documents instead of using traditional relational database tables with rows and columns

    1. db.collection.insertOne(): This command is used to insert a single document into a collection in MongoDB
    2. db.collection.find(): This command is used to retrieve documents from a collection in MongoDB. It can be used to find all
      documents in a collection or to find documents that match a specific condition

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment