- What is the difference between SQL and NoSQL?
- What is referencing and what is embedding in MongoDB?
- Why should we embed more than referencing when we can in MongoDB?
- When should we prefer referencing over nesting in MongoDB?
- What is the difference between a table and a collection?
-
-
Save hiba-machfej/e96e1a7fb01a9dbdd53fb4586df48d11 to your computer and use it in GitHub Desktop.
Afeaa , Halwest , Shakar
- NoSQL databases are non-relational databases that store data in a manner other than the tabular relations used within SQL.
2.Embedding
involves storing related data directly within a single document. Imagine a document for a user that includes an embedded sub-document for their address. This way, all the user's information is in one place.
Referencing
, on the other hand, stores related data in separate documents but links them together using identifiers. For instance, a user document might have a reference field containing the ID of another document that stores their address.
3.Small Subdocuments
Data that does not change often
Eventual consistency is acceptable
Documents that grow slowly
Data that will require more than one queries to fetch
Fast reads
4.Large Subdocuments
Volatile data
Immediate consistency is necessary
Documents that grow fast
Data often excluded from desired results
Fast Writes
5.Table:
Type: Relational Database
Structure: Rows and columns, fixed schema
Query Language: SQL
Example: users, products
Collection:
Type: NoSQL Database
Structure: Documents, flexible schema
Query Language: Database-specific
Example: users, products
Ahmed Isam, Bahram Baqer, Eman Jamal, Payam R.
Q1-What is the difference between SQL and NoSQL?
A-
- SQL databases are structured,
- rigid,
- follow a predefined schema,
- offering strong consistency and ACID transactions,
- suitable for complex queries and structured data.
- NoSQL databases are flexible,
- scalable horizontally,
- schema-less or schema-flexible,
- prioritizing availability and partition tolerance,
- ideal for unstructured or semi-structured data and high-throughput applications.
Q2- What is referencing and what is embedding in MongoDB?
A-Referencing: In MongoDB, referencing means storing related data in separate collections and using references or IDs to link them.
Embedding: Embedding involves storing related data within a single document in MongoDB.
Q3- Why should we embed more than referencing when we can in MongoDB?
A-Embedding can be more efficient for read operations since it retrieves all related data in one query, reducing the need for joins. It simplifies data retrieval and can improve performance for data that is frequently accessed together.
Q4- When should we prefer referencing over nesting in MongoDB?
A-Use referencing when data is frequently updated, as it avoids the need to update multiple documents. Referencing is also beneficial when the related data might be accessed independently from the main document.
Q5 What is the difference between a table and a collection?
A-Table: In SQL, a table is a collection of rows that conform to a schema, with each row representing a record.
-Collection: In MongoDB, a collection is similar to a table but does not enforce a schema, allowing for more flexible document structures.
Mohammed Nazar, Dawood Alkawaz, Hana Abduallah, Elaf Gardi.
- NoSQL Schema is more flexible , it can grow horizontally and it has faster queries and we can use Json with NoSQL.
- Embedding is about putting new data to the document as new filed while referencing is creating another collection to have a new entity with a filed that has a reference for the main document.
- prefer embedding by default for efficiency and ease of access. Use references when data independence or shared access is necessary.
- When we have a new distinct entity having its own properties and when you might want to have the new data accessed separately.
- When you create a table you must have a schema with datatypes and stick to that.
Group : Nada Al Shakiry | Dilan Ahmed | Ahmed Sabah | Helin tayab | Mohammad Sabah
- Initially SQL and NoSQL are the same in terms of being Database management, but they are differ in terms of
Data modeling and Scalability : data is more stored and organized in table like striucture in SQL but in NoSQL databases are flexible organized similar to JSON. Also, SQL is more vertically modeled data in which we have the date over one big server while we have the data over smaller servers in NoSQL horizontally distributed.
Also they differ in Schema in which SQL is more solid while NoSQL is more dynamic.
they are also differ in Transactions and Use Cases as well.
-
in referencing the data are associated to each other from one document to another based on the shared id , while in embedding is more like nesting the information inside one collection in which they are related to each other. Also, the referencing is more slower in comparison to embedding and embedding is more faster as there are less queries and faster fetching.
-
We think it is better to use embedding over using referencing as the embedding is more faster in terms of fetching data and less queries required to return data which makes it more simple in terms of structuring database and manipulation of the data as well. Therefore, it is much better to use embedding over referencing as reference involves more queries and slower, yet the referencing is better usage for complex relational databases.
-
we think using referencing for having multiple relationships, consistent data, avoiding duplication of data, having large embedded dat.
-
SQL uses tables that have a predefined structure, while NoSQL databases like MongoDB are flexible with how data is stored.
-
In MongoDB, referencing keeps related data in a separate collection and links it using IDs. Embedding puts related data directly in the parent document.
-
Embedding is usually better for performance since it avoids joins. Keeping related data together makes queries faster.
-
Reference if related data may change a lot or get too big. This way it can grow without slowing down the parent document.
-
SQL tables enforce structure and data types, while MongoDB collections are flexible - they can hold different document types.
Written by Room 10 members:
- Zainab Alnajjar
- Zainab Mirza
- Hanan Islam
- Sajad Ismael
1- a- SQL databases are primarily called Relational Databases (RDBMS); whereas NoSQL databases are primarily called non-relational or distributed databases.
b- SQL databases are vertically scalable, while NoSQL databases are horizontally scalable.
2- referencing involves storing references to documents in other collections, while Embedding involves nesting one document within another document
3- it will make the performance more quickly, when we have small collections of data we should use embeding.
4- Referencing is preferred when the related data is large or subject to frequent updates
5- table is used with relational database while collection is used with nosql.
Shinak Mohemed, Ali Izzaldin, Shvan Abdulhakeem, ahmed jalal