Ch4 Flashcards

(57 cards)

1
Q

[DB DESIGN] “All students in a university” is an example of what database design concept?

A

Entity set (or Entity class).
WHY: In database modeling, an entity set represents a broad collection of objects or concepts of the same type that share the same attributes.

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

[DB DESIGN] Reinforcement: Define an entity set in plain English.

A

A collection of similar items that share the same properties and will eventually become a table in your database.
MNEMONIC: SET means a STACK OF EQUIVALENT THINGS.

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

[DB DESIGN] Mastery: Business Scenario: If “Student” is an entity set, what is “John Doe, ID 12345”?

A

An entity instance (or simply an entity).
EDGE CASE: An entity set can technically be empty in the database before the first student record is actually created.

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

[DB DESIGN] A small company database has an Order entity that cannot exist without a Customer. Each order is identified only by the customer who placed it. What type of entity is this?

A

Weak entity.
WHY: It lacks a primary key of its own and depends entirely on an identifying relationship with a parent entity to exist.

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

[DB DESIGN] Reinforcement: Define a weak entity in plain English.

A

An entity that requires a relationship with another specific entity to exist and be uniquely identified.
MNEMONIC: WEAK entities need a STRONG parent to survive.

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

[DB DESIGN] Mastery: Business Scenario: If a weak entity “Dependent” is linked to an “Employee”, what happens if the “Employee” record is deleted?

A

The “Dependent” records must also be deleted (known as a cascade delete), because a weak entity cannot exist in the database without its identifying parent.

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

[DB DESIGN] “Manager manages Employee”, where both are in the same Employee table, is an example of what type of relationship?

A

Unary relationship (or Recursive relationship).
WHY: An entity type is relating back to itself within the same table.

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

[DB DESIGN] Reinforcement: Define a unary relationship in a database.

A

A relationship that exists between instances of a single, identical entity type.
MNEMONIC: UNARY means UNO, one table relating to itself.

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

[DB DESIGN] Mastery: Business Scenario: How do you physically implement a unary relationship like “Employee manages Employee” in SQL?

A

Add a “ManagerID” column to the Employee table that functions as a foreign key pointing to the same table’s “EmployeeID” primary key.

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

[DB DESIGN] What does “modality” refer to in a database relationship?

A

The minimum number of entity occurrences that can be involved in a relationship (typically 0 for optional, or 1 for mandatory).
WHY: Modality differentiates between what CAN happen and what MUST happen in the business logic.

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

[DB DESIGN] Reinforcement: Define modality in database design in plain English.

A

The structural rule determining if participating in a relationship is optional or required.
MNEMONIC: MODALITY means MANDATORY OR DISCRETIONARY.

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

[DB DESIGN] Mastery: Business Scenario: If a customer can register an account without placing an order, what is the modality of the Order entity?

A

Optional (0). The minimum number of orders required for a newly registered customer is zero.

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

[DB DESIGN] If a student must be enrolled in at least one course, the modality for “Course” in the “Student-EnrollsIn-Course” relationship is:

A

Mandatory (or 1).
WHY: The word “must” implies a strict minimum requirement of 1, meaning the relationship is not optional.

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

[DB DESIGN] Reinforcement: Define a mandatory relationship constraint.

A

A condition where an entity must actively participate in a relationship for the record to be valid.
MNEMONIC: MANDATORY means MUST HAVE.

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

[DB DESIGN] Mastery: Business Scenario: How is a mandatory modality enforced at the table level in an SQL database?

A

Using constraints like NOT NULL on foreign keys, or utilizing application-level validation triggers before an INSERT occurs.

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

[DB DESIGN] An associative entity is used to represent what kind of relationship?

A

A many-to-many (M:N) relationship.
WHY: Relational databases cannot directly store many-to-many relationships, so an associative table breaks it into two readable one-to-many relationships.

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

[DB DESIGN] Reinforcement: Define an associative entity in plain English.

A

A table created purely to connect two other tables that have a many-to-many relationship.
MNEMONIC: ASSOCIATIVE entities ASSOCIATE many with many.

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

[DB DESIGN] Mastery: Business Scenario: Can an associative entity have its own data attributes?

A

Yes. For example, an Enrollment associative entity connecting Students and Courses will typically store the “Grade” for that specific student-course combination.

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

[DB DESIGN] The database tracks that a doctor prescribes a medication to a patient. What type of relationship is this?

A

Ternary relationship (Degree 3).
WHY: The specific event (prescription) simultaneously involves three distinct entities: Doctor, Patient, and Medication.

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

[DB DESIGN] Reinforcement: Define a ternary relationship.

A

A simultaneous association among instances of three completely different entity types.
MNEMONIC: TERNARY equals THREE interacting tables.

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

[DB DESIGN] Mastery: Business Scenario: How do you resolve a ternary relationship into a relational database schema?

A

Create a central associative entity that contains foreign keys pointing to all three participating primary entities (e.g., DoctorID, PatientID, and MedicationID).

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

[DB DESIGN] A “required” attribute in an Entity-Relationship Diagram is typically indicated by:

A

Bold text in ERDs, and implemented as a NOT NULL constraint in the physical database schema.
WHY: It prevents the database from accepting a row if that specific mandatory column is empty.

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

[DB DESIGN] Reinforcement: Define a required attribute constraint.

A

A structural rule stating a specific data field cannot be left blank during data entry.
MNEMONIC: REQUIRED means REJECTED IF BLANK.

24
Q

[DB DESIGN] Mastery: Business Scenario: What happens if an application tries to insert a record missing a required attribute?

A

The Database Management System (DBMS) will throw a fatal error and abort the entire transaction to maintain strict data integrity.

25
[DB DESIGN] A database tracks Courses and CourseSections. Each CourseSection cannot exist without a Course, and its primary key is the course code. What type of entity is Course?
A strong entity (or parent/identifying entity). WHY: The Course exists entirely independently and provides the core identity for the dependent weak entity (CourseSection).
26
[DB DESIGN] Reinforcement: Define a strong entity.
An entity that exists independently of other entities and contains its own unique primary key. MNEMONIC: STRONG entities STAND ALONE.
27
[DB DESIGN] Mastery: Business Scenario: In the strong/weak entity relationship between Course and CourseSection, which table must be created and populated first?
The strong entity (Course) must be created first so the weak entity has a valid, existing foreign key to reference.
28
[DB DESIGN] Which of the following pairs best illustrates a supertype/subtype relationship?
Employee (Supertype) and HourlyEmployee / SalariedEmployee (Subtypes). WHY: Subtypes inherit universal attributes from the supertype but possess their own highly specific attributes.
29
[DB DESIGN] Reinforcement: Define supertype and subtype in database design.
A supertype is a generic parent category, and a subtype is a specific sub-category that inherits properties from the parent. MNEMONIC: SUPER is GENERAL, SUB is SPECIFIC.
30
[DB DESIGN] Mastery: Business Scenario: Why use a supertype/subtype structure instead of one giant table for all Employees?
To avoid massive numbers of NULL values. Instead of having empty unused columns for "HourlyWage" on salaried workers, those specific columns exist only in the HourlyEmployee subtype table.
31
[DB DESIGN] What is a partition in the context of supertypes and subtypes?
A structural constraint determining if subtypes are mutually exclusive (disjoint) or overlapping, and defining partial or total completeness. WHY: It establishes strict business rules about exactly how data must be categorized.
32
[DB DESIGN] Reinforcement: Define the disjoint rule in partitioning.
A rule stating that an entity instance can belong to ONE AND ONLY ONE subtype at a time. MNEMONIC: DISJOINT means DISTINCT AND DIVIDED.
33
[DB DESIGN] Mastery: Business Scenario: Is a "Patient" supertype partitioned into "Outpatient" and "ResidentPatient" typically overlapping or disjoint?
Disjoint. In most hospital business logic, a patient cannot be simultaneously an admitted resident and an outpatient at the exact same moment.
34
[DB DESIGN] How is a many-to-many relationship physically implemented in a relational database?
By creating a third table (an associative or junction table) that holds foreign keys referencing the primary keys of the original two tables. WHY: Relational database models cannot natively store arrays or lists of pointers inside a single column.
35
[DB DESIGN] Reinforcement: Define a junction table.
A connecting table used to split a complicated many-to-many relationship into two simpler one-to-many relationships. MNEMONIC: JUNCTION tables JOIN TWO TABLES.
36
[DB DESIGN] Mastery: Business Scenario: If you implement a many-to-many relationship between "Students" and "Classes", what is the primary key of the new junction table?
It is typically a composite primary key made of both foreign keys combined (StudentID + ClassID).
37
[DB DESIGN] In a database, each student has a unique StudentID and a DateOfBirth. Which of the following best describes the functional dependency between the two?
DateOfBirth is functionally dependent on StudentID (StudentID determines DateOfBirth). WHY: Knowing the unique ID mathematically guarantees knowing the exact, singular birth date associated with it.
38
[DB DESIGN] Reinforcement: Define functional dependency in databases.
A relationship where the value of one specific attribute uniquely and consistently determines the value of another attribute. MNEMONIC: DEPENDENCY means ONE DEFINES THE OTHER.
39
[DB DESIGN] Mastery: Business Scenario: Can functional dependency work in reverse? Does DateOfBirth functionally determine StudentID?
No. Many different students can share the exact same DateOfBirth, so DateOfBirth cannot uniquely identify a specific StudentID.
40
[DB DESIGN] An Employee table has a primary key (EmployeeID), and each column contains only atomic values. Which highest normal form is this table in?
First Normal Form (1NF). WHY: 1NF strictly requires atomic values and a defined primary key. Without data on partial or transitive dependencies, we cannot claim 2NF or 3NF.
41
[DB DESIGN] Reinforcement: Define First Normal Form (1NF).
A database rule stating each cell must hold a single, indivisible value and every row must be unique. MNEMONIC: 1NF means 1 VALUE PER CELL.
42
[DB DESIGN] Mastery: Business Scenario: Why does a comma-separated list of "PhoneNumbers" in a single column violate 1NF?
Because the value is not atomic. It makes querying for a specific phone number or updating a single number computationally expensive and prone to data anomalies.
43
[DB DESIGN] Consider a table OrderDetails with columns (OrderID, ProductID, ProductName, Quantity). If ProductName depends ONLY on ProductID, which normal form is violated?
Second Normal Form (2NF). WHY: The primary key is a composite of OrderID + ProductID. ProductName depends on only a PART of that primary key, creating a partial dependency.
44
[DB DESIGN] Reinforcement: Define Second Normal Form (2NF).
A rule stating a table must already be in 1NF and have absolutely NO partial dependencies. MNEMONIC: 2NF means NO PARTIAL KEYS.
45
[DB DESIGN] Mastery: Business Scenario: How do you fix the 2NF violation in the OrderDetails table?
Remove ProductName from the OrderDetails table entirely, and create a separate "Products" table where ProductID is the primary key and ProductName is a dependent attribute.
46
[DB DESIGN] A small company database has a table OrderDetails with columns: (OrderID, ProductID, ProductName, Quantity). What is the primary key?
A composite primary key consisting of both OrderID and ProductID. WHY: Neither ID alone is unique in this specific table, but the combination of the two guarantees a unique row.
47
[DB DESIGN] Reinforcement: Define a composite primary key.
A primary key made up of two or more columns that work together to uniquely identify a single row. MNEMONIC: COMPOSITE means COMBINED COLUMNS.
48
[DB DESIGN] Mastery: Business Scenario: What is an architectural alternative to using a composite primary key in an OrderDetails table?
Adding a brand new surrogate key column, like an auto-incrementing "OrderDetailID", to serve as a clean, single-column primary key.
49
[DB DESIGN] "Which of the following statements is true?" (Addressing General DB Constraints): A foreign key must either match a primary key value in another table or be:
NULL. WHY: This enforces referential integrity so there are no "orphan" records pointing to non-existent data.
50
[DB DESIGN] Reinforcement: Define referential integrity.
The structural rule that guarantees relationships between tables remain consistent and valid over time. MNEMONIC: REFERENTIAL INTEGRITY means RELIABLE REFERENCES.
51
[DB DESIGN] Mastery: Business Scenario: If you try to insert an Order for a CustomerID that does not exist in the Customers table, what happens?
The database actively rejects the insert operation due to a referential integrity constraint violation.
52
[DB DESIGN] If a strict one-to-one relationship is implemented, the foreign key column must be constrained as:
UNIQUE. WHY: This constraint ensures that no two records in the child table can point to the same record in the parent table, mathematically preserving the 1:1 ratio.
53
[DB DESIGN] Reinforcement: Define a UNIQUE constraint in SQL.
A database rule that prevents duplicate values from being entered into a specific column across all rows in a table. MNEMONIC: UNIQUE means UNDUPLICATED.
54
[DB DESIGN] Mastery: Business Scenario: How is a 1:1 relationship between "Employee" and "CompanyCar" implemented?
The CompanyCar table gets an "EmployeeID" foreign key, and a UNIQUE constraint is placed on it so one single employee cannot be assigned multiple cars.
55
[DB DESIGN] Consider a 'Car' table where 'VIN' and 'LicensePlate' are both unique identifiers. Which of the following is a superkey but NOT a candidate key?
Any combination that includes a candidate key plus extra attributes, for example: {VIN, Make}. WHY: A candidate key is minimal (just VIN). A superkey is ANY unique identifier, even if it contains bloated, unnecessary columns.
56
[DB DESIGN] Reinforcement: Define the exact difference between a candidate key and a superkey.
A superkey is any combination of columns that uniquely identifies a row; a candidate key is a superkey stripped down with absolutely no unnecessary columns. MNEMONIC: SUPERKEY is BLOATED, CANDIDATE KEY is LEAN.
57
[DB DESIGN] Mastery: Business Scenario: If {LicensePlate} is a valid candidate key, why might the database designer still choose {VIN} as the actual primary key?
License plates can change over the lifespan of a car (if sold to another state), whereas the VIN is completely permanent, making VIN a significantly more stable primary key.