- 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 : Wajd , Rinad, Feda
Q1: SQL : Structured Query Language, Organized into columns and rows within a table, SQL databases use a relational model that work best with well-defined structured data,SQL databases are scalable vertically, based on schema
NOSQL : non-relational databases , NoSQL databases are scalable horizontally , work well with unstructured data , NoSQL is schema-less (no fixed data model).
Q2: In referencing, relationships between documents are modeled by storing references (usually, the _id field) from one document to another. Referencing is useful when there is a one-to-many or many-to-many relationship between entities, and we want to avoid duplicating data.
In embedding, related data is stored directly within a document, eliminating the need for separate collections and references.
This is suitable for one-to-one or one-to-few relationships where the related data is small and doesn't change frequently.
Q3:Embedded documents are an efficient and clean way to store related data, especially data that’s regularly accessed together.
Embedded documents are stored as children inside a parent document. This means they are all stored under one collection, and whenever you retrieve the parent document, you also retrieve all its embedded documents.
Q4: If the related data is large or changes frequently, referencing can be more efficient , allow to perform , Referencing allows you to perform more complex queries that involve filtering, sorting, and aggregating related data independently. This flexibility can be crucial for certain reporting or analytical scenarios.
Q5-ORM stands for Object-Relational Mapping. It is a programming technique that converts data between incompatible type systems in object-oriented programming languages. In the context of databases, an ORM is a tool or library that simplifies database interactions by abstracting the database operations and allowing developers to work with objects in their programming language, rather than dealing directly with SQL queries. it help with code readability and productivity
Q6- Table (Relational Database):
In a relational database, data is organized into tables. A table consists of rows and columns, where each row represents a record, and each column represents a field or attribute. Tables are connected through relationships, and the structure of the data is defined by a fixed schema.
Collection (NoSQL Database):
In NoSQL databases, particularly document-oriented databases like MongoDB, data is organized into collections. A collection is a grouping of MongoDB documents. Each document is a set of key-value pairs, and collections are schema-less, meaning each document in a collection can have different fields. Collections in NoSQL databases are similar to tables but are more flexible and don't enforce a fixed schema.