chapter 2 Flashcards
(14 cards)
Q: What is a relation in the relational data model?
A: A relation is a table with rows (tuples) and columns (attributes) in a relational database.
Q: What is a tuple in a table?
A: A tuple is a single row in a table, representing a single record.
Q: What is an attribute?
A: An attribute is a column in a table, representing a property of the entity (e.g., Name, Age).
Q: What is the schema of a relation?
A: The schema defines the structure of a table, including its name, attributes, and data types.
Q: Name the four main types of constraints in the relational data model.
Domain Constraints: Restrict values in an attribute (e.g., Age must be a number).
Key Constraints: Ensure each row is unique (e.g., Primary Key).
Entity Integrity: The primary key cannot be NULL.
Referential Integrity: Foreign keys must match primary keys or be NULL.
Q: What is a primary key?
A: A unique identifier for each tuple (row) in a table.
Q: What is a foreign key?
A: An attribute in one table that references the primary key of another table to create relationships.
Q: What is cardinality in a relation?
A: The number of rows (tuples) in a table.
Q: What is degree/arity in a relation?
A: The number of columns (attributes) in a table.
Q: What is the difference between a candidate key and a super key?
Candidate Key: A minimal set of attributes that can uniquely identify a row.
Super Key: Any set of attributes that uniquely identify a row (may include extra attributes).
Q: What is a composite key?
A: A primary key made up of two or more attributes.
Q: What does the Referential Integrity Constraint ensure?
A: It ensures that a foreign key value matches a primary key value in the referenced table or is NULL.
Q: What is the difference between a simple and composite attribute?
Simple Attribute: Cannot be divided (e.g., Age).
Composite Attribute: Can be divided into smaller parts (e.g., FullName → FirstName, LastName).
Q: What is the main purpose of constraints in a relational database?
A: To ensure data accuracy, consistency, and integrity.