3+4 Flashcards
What were the previous database models? What is the current one?
Hierarchical (tree structure, bad because adding anything required a parent). Network. Currently used model is relational model.
What are the core components in the relational model?
How does it work?
Objects (or relations), which form the structure.
Integrity, the enforcing of constraints and rules.
Operators, for data manipulation.
Each relation is a table of values: A row is a tuple, a collection of related data values. A column is an attribute.
What is a domain?
a set of atomic values, with a data type or format.
What is a relation schema made up of? What is a degree?
a relation name, and a set of attributes. The degree of a relation is the number of attributes in the schema.
What does NULL mean?
Can mean many things, e.g that the value is unknown, or that it does not apply.
What are restraints and what types are there?
Restrictions on the values in the database, these can be:
- domain contraints
- key constraints and constraints on NULL
- Integrity constraints
- Semantic Integrity constraints
- Functional dependency constraints.
What is a domain constraint?
Specify the domain of an attribute.
What is a superkey, how does this apply to key constraints?
firstly: no two tuples can have all the same values.
A superkey is a set of attributes such that for any two distinct tuples the superkeys are not identical.
A key is a minimal superkey, meaning no more attributes can be taken away. There can be more than one possible key, each of which is named a candidate key. One of these candidate keys is known as the primary key.
What is an integrity constraint? What are two important examples?
specified on database schema, holds every valid database state of the schema, e.g domain, key, NOT NULL.
An entity integrity constraint means no primary key values can be NULL.
A referential integrity constraint ensures if another entity is referenced, it must exist.
What is a foreign key?
A set of attributes which references another relation, must satisfy two conditions:
1. Same domain as primary key attributes of second relation.
2. The values specified must be either NULL or reference an existing entity in the second relation.
The first relation is the referencing, the second is the referenced.
What are semantic integrity constraints and functional dependency constraints?
Semantic: salary of employee should not exceed salary of supervisor.
Functional dependency: establish functional relationship among two sets of attributes X and Y.
What are the steps in mapping an ER diagram to relational database model?
1: Map regular entity types
- Create a relation that has all simple attributes. Include simple components for composite.
- Choose one key attribute of E as primary key
- Map weak entity types
- Create a relation that includes all simple attributes and components.
- Primary key of owner entity becomes foreign key of weak entity relation.
- Primary key is primary key of owner + partial key. - Map binary 1:1 relationship types
- Choose one participating relation, include primary key of second relation as foreign key in first. Should choose one with total participation.
- Add all simple attributes of relationship. - Map binary 1:N relationship types
- Include foreign key in the N side entity of the relationship.
- Include simple attributes of relationship. - Map binary M:N relationship types
- Create new relationship, include foreign keys of both parties in the relationship. Combination forms primary key.
- include simple attributes of relationship. - Map multivalued attributes
- Create new relation
- has an attribute corresponding with multi value attribute, primary key is foreign key of original entity + attribute. - Map N-ary relationship types
- create new relation.
- primary key is foreign key of each participating entity.
- include simple attributes.
What are the operators in the relational database model?
Special relational operators: Select(or ‘restrict’), project, join, divide
Set operators: Union, intersection, difference, cartesian product.
What does the select operator do?
Works on a single relation ans selects a subset based on selection_condition. It is commutative(order of selects doesn’t change result) and a cascade can be combined into a single SELECT.
What does the project operator do?
Works on single relation, defines a relation containing a vertical subset of the original relation. Eliminates duplicates. Is not guaranteed to be commutative.