week 3 : relational data model Flashcards
(18 cards)
what is a relational data model?
- based on the mathematical concept of a relation
- organizes and represents data in a form of a table
relation
a table with rows and columns
tuple
row of a relation
attribute
a named column of a relation
degree (of a relation)
number of attributes in a relation
cardinality (of a relation)
number of tuples in a relation
domain
set of allowable values for each attribute
relational model terminology
- base relation
- view
base relation
a named relation corresponding to an entity in conceptual schema, whose tuples are physically stored in a database
view
- dynamic result of one or more relational operations operating on base relations to produce another relation
- a virtual relation that does not necessarily actually exist in the database but is produced upon request (at time of request)
- dynamic : changes made to base relations that affect view attributes are immediately reflected in the view
- contents of a view : query on one or more base relations
properties of relations (1-3)
1) relation name is distinct from all other relation names in relational schema
2) each cell of relation contains exactly one atomic (single) value
3) values of an attribute are all from the same domain
properties of relations
4) each attribute has a distinct name
5) each tuple is distinct (no duplicates)
6) order of attributes has no significance
7) order of tuples as no significance
relational keys
- candidate key
- primary key
- alternate key
- foreign key
candidate key
- any minimal set of attributes that can uniquely identify each tuple in relation
- relation may have 1 or more candidate keys
- consists of a single attribute or multiple attributes
- multiple attribute keys = composite keys
primary key
one candidate key –> primary key whose values are used to identify tuples uniquely in a relation
alternate key
candidate keys that are not selected to be the primary key
primary key criteria
- minimal set of attributes
- less likely to have its values changed
- less likely to lose uniqueness in the future
- fewest characters
- easier to use from the user’s POV
foreign key
- attribute which provides a logical link between tables
- an attribute/set of attributes within one relation (r1) that matches the candidate key of some relation (r2), (can be the same key)