Module 2 Flashcards
Relational Data Model
4 basic concepts of the relational model?
- relations
- attributes
- domains
- tuples
relation?
the main construct for representing data. Informally, it is a set of records and similar to a table with columns and rows
is every table a relation?
no, every relation is a table but not every table is a relation
what are the key components of a relation?
- relation name
- attribute names
- tuples (rows)
- attribute values from the same domain
domain types?
the data type or format that a certain attribute will accept.
E.g. only accepting positive integers
attributes?
attribute is the name of a role played by some domain in the relation
E.g. the attribute salary must belong to the domain of salary
The number of attributes in a relation R is called the degree of R
domain/attribute restrictions?
same attribute name does not necessarily imply same domain
E.g. attribute ID exists for two entities but the format/range is different (1int vs. 4ints)
vice versa
different attribute name does not necessarily imply different domain
E.g. ID vs managerID (different attribute names but both are 4ints)
tuples?
tuple (t) is an ordered list of n values
where each value is an element of the corresponding attribute or the special NULL value
E.g. (1234, Ephraim, 23, NULL) is a 4-tuple
relation schema?
denoted by R[A1, A2, A3, …, A(n)] includes a relation name (R) and list of attributes A1, A2, A3, …, A(n)
E.g. A relation schema of degree 5
Employee [id, name, sex, salary, department]
integer n is “degree of relation” (how many attributes)
relation instance?
relation instance (r) of the relation schema (R), denoted by r(R), is a set of n-tuples r = {t1, t2, …, t(m)}
in normal English, a set (instance) of tuples of relational type R
E.g. a table of the same type of tuple (employee table)
ordering of tuples?
mathematically, no implied order
semantically, order irrelevant
physically, reside in blocks of storage with partial ordering therefore TUPLES HAVE AN ORDERING
ordering of values within a tuple?
syntactically, all tuples in a relation have same order
semantically, order chosen is irrelevant as long as the values are matched with the correct attribute
database integrity constraints?
rules, that every instance, of the schema must hold (as well as the transitions of the schema)
- domain
- key
- entity integrity
- referential integrity
- semantic integrity
domain constraints?
using incorrect data type
E.g. using string when attribute is type integer
key contraint?
keys must remain unique at all times