Identifying a Primary Key
In designing a table to store customer records, which attribute is best suited to be used as the primary key?
- customer_id
- first_name
- date_of_birth
- email_adress
- adress_id
Foreign Key Purpose
What is the main purpose of a foreign key in a relational database schema?
- It enforces referential integrity between related tables
- It increases the speed of SELECT queries
- It makes data types more flexible
- It automatically generates unique values
- It stores multiple data values in one column
Selecting Appropriate Data Types
You need to store product prices with two decimal places in a table. Which data type is most appropriate?
- DECIMAL
- VARCHAR
- INTIGER
- BOOLIAN
- DATETIME
Establishing Table Relationships
Given two tables: Orders and Customers, which method most effectively links each order to the correct customer?
- Include a customer_id foreign key in the Orders table
- Repeat the customer's name in every order record
- Store all order IDs inside the Customers table as a list
- Connect tables only by similar column names
- Use a calculated column to match orders to customers
Data Integrity Violation Scenario
Which action would violate referential integrity in a schema with an 'Order' table referencing a 'Product' table using a foreign key?
- Deleting a Product that is referenced by an Order
- Adding a new Product with a unique product_id
- Updating an Order's quantity value
- Changing a Product's price
- Renaming a column in the Order table
Choosing Unique Constraints
Which constraint ensures that no two records in a table have the same value in a particular column?
- UNIQUE
- FOREIGN
- REFERANCE
- DEFAULT
- CASCADE
Denormalization Risks
What is one risk of denormalizing a relational database schema for read performance?
- It can increase data redundancy, leading to inconsistencies
- It will always make queries slower
- It removes the need for primary keys
- It disables foreign key constraints
- It turns all tables into flat files
Composite Primary Keys
When would you use a composite primary key for a table?
- When a single column cannot uniquely identify each row
- When every table must have at least two primary keys
- When you want to use foreign keys in another table
- When storing a list of emails in one column
- When defining a table without any columns
Many-to-Many Relationships
How do you typically model a many-to-many relationship between two tables?
- Introduce a junction (or associative) table linking their primary keys
- Add all attributes from both tables into one giant table
- Use ENUM data types to store references
- Store lists in a single column
- Omit primary keys from both tables
Schema Documentation Importance
Why is comprehensive schema documentation important in database design?
- It helps new team members understand the structure and constraints
- It prevents all database errors automatically
- It replaces the need for indexes
- It controls data access at the hardware level
- It eliminates the requirement for foreign keys