Lecture 3: Relational Model Flashcards
Explain what a relational Model is.
- in a relational model all data is structured within relations (tables).
- this is the dominant database solution
So what is a relation?
table with columns and rows
What is an attribute?
a column of a relation
What is a tuple?
a row in a relation.
what is a domain?
set of allowable values for one or more attributes.
Explain the term degree (of a relation).
number of attributes it contains
Describe Cardinality (of a relation)
number of tuples it contains.
In a relational model we have constraints that impose restrictions on values in a column or a combination of columns within a table.
What is a constraint?
a column or a group of columns must be unique across all rows in the table.
Explain what a: Superkey, Candidate Key and Primary Key is.
Superkey: attribute or set of attributes that uniquely identify a typle in a relation.
Candidate Key: a superkey such that none if its subset is a superkey for that relation. e.g.
- its unique
- itrs irreducible.
Primary Key: the candidate key that is used to uniquely identify tupes in a relation
- thus, there may be candidate keys, but only one is chosed as PK
Explain what a Foreign Key is.
- an attribute or a set of attributes within one relation (home relation), that matches the candidate key in another relation.
- The foreigner key targets the candidate key in the home relation.
Explain the use of Null
- represents a value that is unknown or the absence of a value
- null can be used when we dont know the value for an attribute to prevent inserting a false value.
- stock = 0, stock = null. is not the same
Name and provide a description of the two Integrity constraints.
Entity integrity: no attribute of a primary key can be null
Referential integrity: if a foreign key exists, either the value of the foreign key matches the value of the candidate key in the home relation or the value of the foreign key is null.
Give the example of how data can be modeled from different perspectives.
Relational Perspective (How the Users view the data):
- Table, Row, Column
Conceptual Perspective:
- Relation, Tuple, Attribute
Storage Perspective (Describes the details of how the data is stored in the computer):
- File, Record, Field
Explain the constraints:
- Entity Integrity
- Referential integrity
- Domain Constraints
- Primary Key Constraints
Referential Integrity: if a foreign key exist, either the value of the foreign key matches the value of the candidate key in the home relation or the value of the foreign key is NULL
Entity integrity: no attribute of a primary key can be NULL
Domain Constraints: the value of each attribute in each tuple must be from the domain assigned to this attribute
Primary Key Constraints: two distinct tuples in any state of the relation cannot have identical values for all attributes in the key