Presentation is loading. Please wait.

Presentation is loading. Please wait.

April 20022CS3X1 Database Design The relational model John Wordsworth Department of Computer Science The University of Reading

Similar presentations


Presentation on theme: "April 20022CS3X1 Database Design The relational model John Wordsworth Department of Computer Science The University of Reading"— Presentation transcript:

1 April 20022CS3X1 Database Design The relational model John Wordsworth Department of Computer Science The University of Reading J.B.Wordsworth@rdg.ac.uk Room 129, Ext 6544

2 April 20022CS3X2 Lecture objectives Describe the main characteristics of the relational model of data. Explain what is meant by entities, attributes, and domains. Explain the various kinds of keys that appear in the relational model. Describe the use of null values for attributes. Define entity integrity.

3 April 20022CS3X3 What is a model? A model is something simple constructed to represent something more complicated. Focuses on certain aspects of the thing modelled. Discards features of the original that are regarded as being unessential.

4 April 20022CS3X4 What is a relation? A relation is a set of tuples – displayed as a table – each row contains information about a single object – each column records a particular piece of information about every object – ordering not significant – duplicates not allowed

5 April 20022CS3X5 Entities Entity –A single object about which information is stored Entity set (C&B: entity type) –A collection of similar objects, the same kind of information being stored about each of them

6 April 20022CS3X6 Degree and cardinality Degree = 3 Cardinality = 5

7 April 20022CS3X7 Attributes and domains: definitions Attribute: a single-valued property of an entity; recorded in a named column of a relation. Domain: analogous to type in conventional programming. Restricts permissible values to specified range or set. Allows dynamic checks of assignments.

8 April 20022CS3X8 Attributes and domains: example Entity type: Person Attributes: Name, Age, Height, Weight, Hair Colour Domain for Hair Colour: –{Ash, Fair, Brown, Auburn, Dark, Grey, Black} Attribute value: Brown

9 April 20022CS3X9 Keys (1) Used in two senses –stronger: unique identification for one row/record/tuple –weaker: specifies ordering on the entity-set –Simple and Composite simple: one attribute is adequate to identify a single entity. composite: two or more attributes taken together are necessary to identify a single entity.

10 April 20022CS3X10 Keys (2) Superkey –a (group of) attribute(s) that uniquely identifies a single row Candidate key –superkey such that no proper subset of it is itself a superkey Primary key –candidate key actually selected to identify rows Foreign key –(set of) attributes in one relation that matches the candidate key of some (possibly the same) relation

11 April 20022CS3X11 Is it a key? Looking at an actual instance of a table can be misleading. –Is surname sufficient? Surname and initials? and date- of-birth? –In one year there were two students named David G Barnes. May need an artificial key –student registration number; national insurance number, for example.

12 April 20022CS3X12 Integrity Null –means "attribute value not known" –Note: this is not the same as a zero value or an empty string. Entity integrity –Every attribute of a primary key must be non- null in every record.

13 April 20022CS3X13 Key points The relational model is a way of looking at data. Data is considered as being stored in tables: rows and columns. The relational model views things as entities with attributes. Every table must have one or more attributes that serve as a key, a unique identifier for each row of the table. A null value can be used to say that an attribute value is not known.


Download ppt "April 20022CS3X1 Database Design The relational model John Wordsworth Department of Computer Science The University of Reading"

Similar presentations


Ads by Google