SQL Flashcards

(4 cards)

1
Q

What are the 4 basic SQL queries?

A
  1. SELECT – Read data
  2. INSERT – Create data
  3. UPDATE – Modify data
  4. DELETE – Remove data
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What types of relationships are possible in a relational database?

A
  1. One-to-One (1:1): Each record in Table A corresponds to exactly one record in Table B, and vice versa, e.g.
    Users (id, name)
    UserProfiles (user_id, bio, avatar_url)
  2. One-to-Many (1:N): One record in Table A relates to many records in Table B, but each record in B relates to only one in A, e.g.
    Authors (id, name)
    Books (id, title, author_id)
  3. Many-to-Many (M:N): Records in Table A can relate to many in Table B, and vice versa, e.g.
    Students (id, name)
    Courses (id, title)
    Enrollments (student_id, course_id) – bridge table
  4. Self-Referencing (Recursive): A row in a table can reference another row in the same table, e.g.
    Employees (id, name, manager_id)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How would you describe the concept of database normalization to a non-developer?

A

Imagine you’re organizing customer information on paper.
- You start with one big sheet per customer that lists their name, orders, shipping address, and the products they bought.
- But you notice:
- The same customer’s info is repeated every time they buy something.
- Product details (like name and price) are copied over and over.
This wastes space, creates errors (typos, outdated info), and makes updating hard. So instead, you:
- Write customer details on one sheet.
- Write product details on another.
- Write orders on a third, linking to the customer and the product.
Now, if a customer changes their address, you only update it in one place. That’s normalization—you’re avoiding repetition, improving accuracy, and making everything more organized.

Normalization is the process of structuring a database to:
1. Eliminate redundant data
2. Ensure each piece of data lives in just one place
3. Make the database easier to update and maintain

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How is data stored in a JSON database?

A

Each record (called a document) is a JSON object, and is stored as-is in the database. Documents are grouped into collections (similar to tables).

Features:
1. Schema-less: No fixed schema — each document can have different fields
2. Hierarchical: Nested objects and arrays are natively supported
3. Flexible: Easy to store complex and evolving data structures
4. Self-contained: All related data can be stored in a single document
5. Human-readable: Raw JSON can be viewed and understood directly

How well did you know this?
1
Not at all
2
3
4
5
Perfectly