- 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:
Team Members: Muna Al Haj Eid, Ahmed Mash, Mo'mena Salloum.
They differ in :
a. Data Model: SQL databases use a relational data model, which stores data in tables with rows and columns. NoSQL databases use a variety of data models, such as key-value, document, column-family, and graph.
b. Scalability: SQL databases are vertically scalable, NoSQL databases, on the other hand, are horizontally scalable.
c. Consistency: SQL databases use ACID transactions to ensure data consistency, NoSQL databases often use BASE transactions.
d. Use Cases: SQL databases are well-suited for transactional systems, such as banking where data consistency is critical. NoSQL databases are well-suited for big data and real-time applications, such as social media where scalability and flexibility are more important.
They are two ways to model relationships between documents.
Referencing involves creating a separate collection for related data and storing the reference to that data in the document.
Embedding involves storing related data within the same document.
Referencing is useful when the related data is large or complex, or when the relationship between the data is many-to-many. Embedding is useful when the related data is small or simple, or when the relationship between the data is one-to-many.
Embedding documents in MongoDB is an efficient and clean way to store related data, especially data that’s regularly accessed together. It allows to define schema in whatever way works for any given application, and nest documents inside each other to create optimal schemas.
Referencing is useful when your data needs to be referred to from multiple locations. If data is only useful in relation to its parent document, embedding is the way to go.
ORM stands for Object-Relational Mapping, it's simply a way to interact with a database like we do in SQL but instead using a programming language, we can also abstract away some of the complexities of interfacing with a database.
Examples:
Without ORM:
SELECT * FROM users WHERE email = '[email protected]';
With ORM:
var orm = require('generic-orm-libarry');
var user = orm("users").where({ email: '[email protected]' });
Table: Typically associated with relational databases, organized in rows and columns.
Collection: Often used in NoSQL databases, a container for diverse or unstructured data without a fixed schema.