Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Relational model concepts Key constraints Referential integrity constraint Steen Jensen, autumn 2013.

Similar presentations


Presentation on theme: "1 Relational model concepts Key constraints Referential integrity constraint Steen Jensen, autumn 2013."— Presentation transcript:

1 1 Relational model concepts Key constraints Referential integrity constraint Steen Jensen, autumn 2013

2  The relational model represents the database as a collection of relations  Each relation resembles a table of values  The data type describing the possible values for each column (attribute) is represented by a domain of possible values, e.g. the data type for Age could be an integer number between 15 and 80 2 Figure 5.1 from chapt. 5 in Elmasri

3  The above representation is also called a relation schema  The degree of a relation is the number of attributes of its relation schema – thus the relation STUDENT has a degree seven  Each value for a specific attribute is atomic - so composite and multivalued attributes are not allowed  The special value called NULL can be used, if the value is unknown or doesn’t apply  Some relations represent facts about entities and other relations represent facts about relationships 3

4  A relation schema may have more than one key – each of the keys is called a candidate key  One of the candidate keys is chosen as the primary key, so it is possible to identify tuples in the relation – thus a primary key can’t have a NULL value  The primary key is underlined 4

5  Referential integrity is used to maintain the consistency among tuples in two relations  The referential integrity states, that a tuple in one relation that refers to another relation must refer to an existing tuple in that relation  To define referential integrity a foreign key is used  The relation in which the foreign key is placed is called the referencing relation, and the relation which the foreign key points to is called the referenced relation  The next slide shows an example of referential integrity 5

6 6

7  Take a look at exercise 5.15 p. 165 in Elmasri chapter 5 (physical page 26)  Make your solution in a format corresponding to the figure shown on the previous slide (approx. 30 minutes) 1. Start by pairing up with the student next to you and suggest the appropriate foreign keys 2. Share and discuss your solution with the other pair of students at your table  Finally the solution should be presented/discussed in class 7


Download ppt "1 Relational model concepts Key constraints Referential integrity constraint Steen Jensen, autumn 2013."

Similar presentations


Ads by Google