- 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 are ORMs? Why we use them? Give an example of an SQL request with and without using ORM.
- What is the difference between a table and a collection?
Some helpful resources:
1- What is the difference between SQL and NoSQL?
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.
2-What is referencing and what is embedding in MongoDB?
Unlike embedded documents, referenced documents are stored in a separate collection to their parent document. Therefore, it's possible to retrieve the parent document without retrieving any of its referenced documents.
3-Why should we embed more than referencing when we can in MongoDB?
Embedded documents are an efficient and clean way to store related data, especially data that's regularly accessed together
choose to embed data instead of referencing it
Performance (Faster Reads/Reduced Latency/Updates)
a combination of embedding and referencing (hybrid approach) is sometimes used to strike a balance between performance and data organization.
4-When should we prefer referencing over nesting in MongoDB?
A document is frequently accessed but contains data that is rarely used.Embedding would only increase in-memory requirements. some situations where referencing might be a better choice than nesting
5-What are ORMs? Why we use them? Give an example of an SQL request with and without using ORM.
Object-relational-mapping is the idea of being able to write queries like the one above, as well as much more complicated ones, using the object-oriented paradigm of your preferred programming language. Long story short, we are trying to interact with our database using our language of choice instead of SQL.
SQL EX:
SELECT * FROM users WHERE email = '[email protected]';
�ORM EX:
var orm = require('generic-orm-libarry'); var user = orm("users").where({ email: '[email protected]' });
6-What is the difference between a table and a collection?
Table(SQL) - RDBMS Maintains relations between the data�Fixed or predefined schema Data is stored in rows and columns Foreign Key relations are supported by DB. Data will not be stored if we violate any of the column data type or foreign key or primary key. Joins can be used effectively to query the data.�Vertically Scalable (would be limited on the hardware, say you cannot keep on adding RAM into a server machine, The machine has its own limit of how much RAM can be increased) Storing and Retrieving is comparatively slower when data is huge. MongoDB Collection - NoSQL DB
No relation is maintained between the data - Dynamic Schema Data is stored as Document Dynamic schema allows to save the document of any data type or any number of parameters. Horizontally Scalable which is simply can be done by adding more servers - Storing and Retrieving is faster No explicit foreign Key support is available whereas we can design the schema by having foreign key(but remember we need to maintain the relationship). $lookup performs similar operation like LEFT OUTER JOIN in SQL.
Team Members : 1- Mohamad Karbejha 2- Mohamad Sheikh Alshabab 3- Hammam Abu Shehadeh