Data Modeling easy
Which real-world relationship is best modeled as 'One-to-Many'?
- A Students and Classes, where an individual student can enroll in multiple subjects, and each subject can contain many distinct students.
- B Person and Passport, where each individual is legally assigned exactly one passport, and that passport cannot be shared by another.
- C Author and Books, where a single author can create many distinct titles, while each individual book is typically associated with one primary creator.
- D Vehicle and VIN (Vehicle Identification Number), where every unique car is manufactured with exactly one permanent identifier.
Answer: C. Author and Books, where a single author can create many distinct titles, while each individual book is typically associated with one primary creator.
The 'One-to-Many' (1:N) relationship is the most common pattern in database design. It is typically implemented by placing a Foreign Key in the 'Many' table (e.g., the `Books` table would contain an `author_id`). Note that 'Students and Classes' is a 'Many-to-Many' (N:M) relationship, which requires a separate join table to resolve properly.
One system design question a day, with spaced repetition so the ones you miss come back.
Get the appRelated questions
- When modeling a Distributed Transaction using the Saga Pattern (Choreography or Orchestration), what type of consistency do you achieve?
- Which practice prevents SQL Injection attacks?
- What is 'Bi-Temporal' data modeling (e.g., in SQL:2011 standard)?
- Adding an Index to a database column generally improves Read performance. What is the negative trade-off?
- Log Systems Merge (LSM) Trees (used in RocksDB, Cassandra) optimize for fast writes. What is their primary downside regarding Disk I/O?
- What is the primary objective of normalizing a relational database schema (e.g., to 3NF)?