Skip to content

Instantly share code, notes, and snippets.

@hiba-machfej
Created April 16, 2024 12:52
Show Gist options
  • Save hiba-machfej/e96e1a7fb01a9dbdd53fb4586df48d11 to your computer and use it in GitHub Desktop.
Save hiba-machfej/e96e1a7fb01a9dbdd53fb4586df48d11 to your computer and use it in GitHub Desktop.

Discuss the answers for these questions with you teammates and write your answers in the comments.

  1. What is the difference between SQL and NoSQL?
  2. What is referencing and what is embedding in MongoDB?
  3. Why should we embed more than referencing when we can in MongoDB?
  4. When should we prefer referencing over nesting in MongoDB?
  5. What is the difference between a table and a collection?
@candourist
Copy link

  1. SQL uses tables that have a predefined structure, while NoSQL databases like MongoDB are flexible with how data is stored.

  2. In MongoDB, referencing keeps related data in a separate collection and links it using IDs. Embedding puts related data directly in the parent document.

  3. Embedding is usually better for performance since it avoids joins. Keeping related data together makes queries faster.

  4. Reference if related data may change a lot or get too big. This way it can grow without slowing down the parent document.

  5. 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

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