Chapter 4 Database Design Flashcards
What is the purpose of the Entity-Relationship Model (ERM) in database design?
ERM is a high-level representation of data requirements, ignoring implementation specifics.
In an airline reservation system, Passenger and Booking are $.
Passenger and Booking are entities.
What would 1 & 2 represent?
- Holds is a relationship between Passenger and Booking.
- PassengerNumber, PassengerName, BookingCode, BookingCost are attributes.
What do entities represent in an Entity-Relationship Model?
Entities aren’t the rows themselves, they define what kind of information those rows will hold.
What are relationships in the context of an Entity-Relationship Model?
Statements about two entities; can be reflexive (entity relates to itself).
What are attributes in an Entity-Relationship Model?
Descriptive properties of an entity.
In SQL implementation, what do entities typically become?
Entities typically become tables.
In SQL implementation, what do relationships become?
Relationships become foreign keys.
In SQL implementation, what do attributes become?
Attributes become columns.
What is an ER Diagram?
A visual representation showing:
- entities as rectangles
- relationships as lines
- attributes as additional text.
Consider the ER Diagram
what would the entity-relationship-entity
be read as?
What does a glossary document?
Glossary or data dictionary
Documents names, synonyms, and descriptions of entities, relationships, and attributes.
Define ‘Entity Type’ in the context of ER modeling.
Set of all instances
(e.g., all employees).
Define ‘Relationship Type’ in the context of ER modeling.
Set of related pairs
(e.g., Employee-Manages-Department).
Define Attribute Type in the context of ER modeling.
Set of values
(e.g., all employee salaries).
What is a supertype entity?
A general category that encompasses subtypes.
What is a subtype entity?
A specific subset of a supertype.
What does ‘IsA’ relationship refer to?
The relationship between a supertype and its subtypes.
A supertype may have $ subtypes.
Multiple
In ER modeling, what notation is used to represent cardinality?
Crow’s Foot Notation.
What does cardinality refer to in Entity-Relationship Modeling?
The maximum and minimum numbers of instances of one entity that can relate to a single instance of another entity.
What are the two maxima in a relationship?
One for each of the related entities, usually specified as either ‘one’ or ‘many’.
What are the typical options for relationship minima?
Zero (optional) or one (required).
What is a partition in the context of supertype and subtype entities?
A group of mutually exclusive subtypes within a supertype.
Why can’t an entity instance be in two subtypes of the same partition?
This is a fundamental rule in entity-relationship modeling and database design.
- Partitions divide an entity type into distinct, non-overlapping groups.
- Subtypes further categorize entities within a partition.
- An entity instance can only exist; in one partition and one subtype within that partition. Example
This ensures data integrity and avoids ambiguity.
How can an entity instance; be in two subtypes of different partitions?
- Subtyping allows an entity to inherit properties and relationships from multiple parent types.
- Still applies if those parent types are defined in different parts of the data model.
What are the main steps in the database design process?
Analysis, Logical Design, Physical Design.
What is the goal of the analysis phase in database design?
Often intertwined with conceptual logic
- Gather data requirements
- To develop the entity-relationship model.
What does the logical design phase involve?
Converting ERM to tables, columns, and keys.
What is the main purpose of the discovery phase in database design?
Identifying entities, relationships, and attributes through interviews with database users and managers.
What types of sources can be used to identify data requirements?
Interviews and written documents.
How should entities be named, when used in terms of conventions?
Singular nouns
(e.g., ‘Employee’).
What format should relationships be named in?
Entity-Verb-Entity
(e.g., Division-Contains-Department).
What is a unique attribute?
An attribute where each entity instance has a unique value across the entire database.
What is a singular attribute?
Each entity instance has at most one attribute value.
What is the relationship maximum for the Employee-Has-Telephone
relationship if each employee can have at most three telephone numbers?
1-3
- “1-3” means an employee must have at least one (“1”) but no more than three (“3”) phone numbers.
- It shows the allowed range, with any number within that range being acceptable.
What is the relationship minimum for the Customer-Has-Identification
relationship if two forms of identification may be required?
1-2
- 1 means at least one form of identification is always required.
- 2 means that in some cases, a second form of identification may also be necessary.
What is the main purpose of documenting cardinality in ER diagrams?
To reflect business rules.
What are the steps in the discovery process?
- The discovery process in design is not a rigid, step-by-step procedure.
- It’s more of an iterative process where designers often move back and forth between different stages as they gather new information and insights.
In database design, when are standard attribute types determined?
ER diagram development.
Identify nouns as _______ in database design.
entities.
Recognize verbs as _______ in database design.
relationships.
Specify nouns as _______ in database design.
attributes.
What are the characteristics of good primary keys?
- Unique
- Not NULL
- Stable
- Simple
- Meaningless
What is the ideal primary key structure?
Single-column primary keys are ideal; composite primary keys can be used if unavailable.
primary key that uses multiple columns in a table to create a unique value for each row
What is the primary key of a subtype table?
Matches the primary key of the supertype.
What do weak entities become in a database?
Weak tables.
How should foreign keys behave when changes are made to the primary key in the parent table?
Think of Customers
and Orders
tables. An order needs a customer, so Orders
uses a foreign key to link to Customers
.
- Cascade on delete: Deleting a customer also deletes their orders.
- Restrict on insert: You can’t create an order for a non-existent customer.
When implementing many-one relationships, where is the foreign key placed?
In the table on the many side of the relationship.
In a one-one relationship, where is the foreign key typically placed?
In the table with fewer rows.
How is a many-many relationship implemented?
Using a new weak table containing two foreign keys.
What is the primary key of the new table in a many-many relationship?
Composite of the two foreign keys.
What do plural attributes become in a database?
New weak tables
- plural attributes are transformed into new weak tables to effectively model many-to-many relationships and maintain data integrity within a database.
What is the SQL data type for a Code attribute?
CHAR(3).
What are the types of attribute cardinality?
- Unique
- Required
- Optional
What SQL keyword enforces unique attributes?
UNIQUE.
What are the criteria for a table to be in First Normal Form (1NF)?
- Every cell contains exactly one value
- The table has a primary key
- No duplicate rows are allowed