Week 2 Flashcards
What is a relationship made up of
- Instance: a table with rows and columns.
#Rows = cardinality, #fields/attributes = degree / arity. - Relation Schema: specifies the relation’s name and type (domain) of each column
E.G. Students(sid:string, name:string, login: string, age:integer, gpa: real)
What is the mathematical notation that can be use to represent a relation schema?
S(A1,A2, A3,… An) Where S is the schema’s name, A is an attribute.
* E.g. Students(sid:string, name:string, login:string, age:integer, gpa:real).
What is the Integrity of data?
It is the state of data in which data obeys the constraints set by DBA.
What is the Domain constraint?
Values in tuples should obey types of attributes.
What is the Key constraint?
Keys of a relation must be unique, non-redundant, and not Null (entity integrity constant).
What is referential integrity?
If two relational schemas are related to each other,
1. The relation must be made by using keys
2. The DBMS must preserve this relation.
3. Foreign keys must have the same type and values in the current relation.
What is a Foreign key?
Set of fields in one relation that is used to ‘refer’ to a tuple/row in another relation. Must correspond to the primary key of the referring relation. Like a ‘logical pointer’.
What is the 4 options on deletes and updates in SQL/92
- Default is NO ACTION (delete/update is rejected)
- CASCADE (also delete all tuples that refer to deleted tuple)
- SET NULL / SET DEFAULT (sets foreign key value of a referencing tuple)
What is an Entity integrity constraint in Key constraints?
A key value cannot be null
What is a superkey?
A set of attributes such that its subset is a key for the relation.
What is the Relation schema in this relationship? How do we link the relationship in the table? What is the integrity constraint?
What is ER-to-Relational Mapping in a 1:1 relationship?
For each 1:1 binary relationship in ER schema, identify relations S and T (in relational schema) that correspond to entity types participating in relationship
Choose on of relations for example, S and include primary key of T as foreign key in S
What is ER-to-Relational Mapping in a 1:N relationship?
For each 1:N binary relationship in ER schema, identify relation S (in relational schema) that represents participating entity at N-side of relationship
Include primary key of relation T as foreign key in S (where T represents entity at 1-side of relationship)
Each entity instance on N-side is related to at most one entity instance on 1-side (primary ke constraint)
What is ER-to-Relational Mapping in a M:N relationship?
For each M:N binary relationship in ER schema, create new relation R to represent many to many relationship
* Include primary keys of relations that represent participating entity types as foreign key attributes in R
* The combination of primary keys of the two relations representing participating entities will form primary key of R