Unit 3 - Relational Model Flashcards
Data model
Collection of high-level data description constructs (e.g., tables and links) that hide many low-level storage details
Relational model
Data is in table(s) (aka RELATIONS, not relationships)
What do rows and columns of relation represent?
Rows are tuples or individual records and columns are attributes (or fields)
Can two relations have the same name?
No, name of relation must be distinct
Can two attributes have the same name if they’re in different relations?
Yes.
In the same relation, each attribute must have a distinct name (we cannot have two or more attributes with the same name)
However, two attributes in different relations can have same name.
Can a cell in a relation have a composite value?
No - each cells contains exactly one atomic (single) value
Can you have different types of values in a column?
No - values of an attribute are all from the same domain
Can you have two duplicate tuples?
No - no duplicate tuples.
What order must the attributes be in?
None. Order of attributes has no importance.
What order must the tuples be in?
None. Tuples can appear in any order (but order may impact efficiency)
What’s a schema?
Header of table: relation’s name, name of each field/attribute, domain of each field
e.g., Students (sid : string , name : string , age : integer , gpa : real)
From ER to relations - Step 1: Translate Entity Sets to Relations Steps
Step 1: each atomic attribute of an entity set becomes an attribute (field) in the relation schema; entity set name = relation name; underline primary key
How do you translate a composite attribute in an ER diagram to schema?
Concatenate the root attribute + composite attribute (order of concatenation doesn’t matter) and that becomes the attribute/field
e.g., let’s say Name is composite and its atomic attributes are First and Last. The employee relation is,
Employee (SSN : integer, First_Name : string, Last_Name : string)
What do derived attributes look like in a relational schema?
They are NOT included
What if there’s a multi-value attribute in the ER? (e.g., multiple email addresses associated with an employee)
You should break that table into two tables:
1. original table minus the email column, and
2. each email address + identifier