Presentation is loading. Please wait.

Presentation is loading. Please wait.

The relational model1 The relational model Mathematical basis for relational databases.

Similar presentations


Presentation on theme: "The relational model1 The relational model Mathematical basis for relational databases."— Presentation transcript:

1 The relational model1 The relational model Mathematical basis for relational databases

2 The relational model2 A bit of history Before 1970: Other types of databases –Hierarchical databases –Network databases 1970 –Codd publishes his famous paper on the relational model 1970’es implementation of the relational model –1976 IBM System R

3 The relational model3 Informal terminology Database = collection of relations Relation (”table”) = set of tuples Tupel (”row”) = list of data

4 The relational model4 Formal definitions (structure) Relational schema R(A 1,..., A n ) –List of attributes A 1,..., A n –Degree of a relation = number of attributes (n) An attribute has a domain A domain D is a set of atomic values like –All Danish first names –Danish post codes

5 The relational model5 Formal definitions (state) Relational state of the relational schema R(A 1,..., A n ) –Set of tuples each containing n attributes r = {t 1,..., t k } Each tuples has n values –t = v i  domain(A i ) or v i = null null is a special value (in every domain) –Data does not exist. –Data unknown (for now).

6 The relational model6 Characteristics of relations Relation = set of tuples –Never 2 equal element in a set  never 2 equal tuples in a relation. –No order among element in a set  no order among tuples in a relation. In a relational schema the order among attributes matter.

7 The relational model7 Constraints Different types of ”rules” –Domain constraints Every value must be atomic - and from the current domain. –Null constraints An attribute may allow or disallow null values. –Key constraints Next slide.

8 The relational model8 Key constraints Every tupel must have a unique key –SK (Super Key) = set of attributes: t1[SK]  t2[SK] for all tuples in R The set of all attributes is always a super key –All tuples in a relation must be unequal –Key = minimal super key –Candidate key when a relation has more keys. –Primary key: One of the candidate keys.

9 The relational model9 Relational schema vs. relational state Relational schema –Structure of the database –Created once Relational state –Content of the database (the data) at at given point of time. –Changes as the database is manipulated using insert, update, delete

10 The relational model10 Integrity Entity integrity –An attribute, that’s part of the primary key, cannot be null. Reference integrity –Relations refer to each other using foreign keys –Referred tuples must exist No “dead” links (unlike the web)

11 The relational model11 Foreign keys –A foreign key is a set of attributes in a relation R 1 refers to the primary key in [another?] relation R 2 –Same number of attributes Composite primary key  composite foreign key! –Same domains –The referred tupel must exist Or the reference must be null!!

12 The relational model12 Updating relations insert new tupel. Take care: –primary key must be unique + not null. –referred tuples must exist delete tupel.Take care: –don’t delete a referred tupel refuse deletion update referring tuples update = delete + insert


Download ppt "The relational model1 The relational model Mathematical basis for relational databases."

Similar presentations


Ads by Google