Presentation is loading. Please wait.

Presentation is loading. Please wait.

Monash University 20041 Week 7 Data Modelling Relational Database Theory IMS1907 Database Systems.

Similar presentations


Presentation on theme: "Monash University 20041 Week 7 Data Modelling Relational Database Theory IMS1907 Database Systems."— Presentation transcript:

1 Monash University 20041 Week 7 Data Modelling Relational Database Theory IMS1907 Database Systems

2 Monash University 20042 Detailed Data Modelling The objective of detailed data modelling is to develop data structures that -have stability, minimum redundancy, and are flexible to allow for future change -can be used as the basis for physical file and database design -reflect the actual data requirements of the system

3 Monash University 20043 To expand the conceptual data model we need to identify and describe –the details of the entities and relationships –attributes (data elements) of entities and relationships An organisation-wide perspective should be adopted to ensure minimum redundancy and inconsistency and to facilitate data sharing Detailed Data Modelling

4 Monash University 20044 Techniques -attribute collection -convert ER models to relations -normalisation -convert to data structure diagram (DSD) Detailed Data Modelling

5 Monash University 20045 At this stage our ER models are logical –independent of implementation technology We shall consider converting our ER models using the relational data model because –it is the most commonly used in DBMS applications –some principles of logical database design for the relational model apply to other logical models –high level of CASE tool support Detailed Data Modelling

6 Monash University 20046 Introduced by E.F. Codd in 1970 Represents data in the form of tables Based on mathematical theory –solid theoretical foundation Three components are considered –data structure –data manipulation –data integrity Relational Data Model

7 Monash University 20047 Data structure –the relational database model represents data in the form of tables or relations Important concepts are -relation -primary key -composite key -foreign key Relational Data Model

8 Monash University 20048 A relation is a named, two-dimensional table of data Each relation consists of a set of named columns and an arbitrary number of unnamed rows Each column corresponds to an attribute of the relation Each row corresponds to an instance (or record) that contains values for an instance of that entity Relations

9 Monash University 20049 A relation generally corresponds to some real world object or concept of interest to the system -similar to an entity Emp#NameSalaryDept 1247 1982 9314 Adams Smith Jones 24000 27000 33000 Finance MIS Finance Employee Employee (Emp#, Name, Salary, Dept) Relations

10 Monash University 200410 Relational tables are tables in which -each relation has a unique name -each attribute or column has a unique name -data values are atomic and single-valued -data values in columns are from the same domain -each row in the relation is unique -the sequence of columns is insignificant -the sequence of rows is insignificant Properties of Relations

11 Monash University 200411 An attribute or group of attributes which uniquely identifies a row of a relation A search criteria that would yield only one record Entity integrity (relational data base theory) requires that each relation has a non-null primary key Represented by underlining the key element –Employee (Emp#, Name, Salary, Dept) Can be a composite key –Order-item (Order#, Item#, Qty-ordered) Primary Key

12 Monash University 200412 Candidate keys –where several possible keys are identified, each of which uniquely identifies the other attributes, they are known as candidate keys - choose one to be the primary key –choose the most stable key or the key over which there is the most control –treat the remaining candidates as non-key attributes we can deal with them later if they give us trouble! Primary Key

13 Monash University 200413 A foreign key is an attribute in one relation that is also a primary key in another relation in the same database –it may be a composite key –allows user to see records in one relation associated with a record in another elation The referential integrity constraint (relational database theory) specifies that if an attribute value exists in one relation then it must also exist in a linked relation A foreign key must satisfy referential integrity Foreign Key

14 Monash University 200414 In the example below, if a given Dept# exists in an Employee relation then that Dept# must exist in the Department relation Employee (Emp#, Name, Salary, Dept#) Department (Dept#, Dname, Budget) foreign key Foreign Key

15 Monash University 200415 The relational model has several constraints or rules that facilitate the maintenance of the accuracy and integrity of data in the database –domain constraints –entity integrity –referential integrity Integrity Constraints

16 Monash University 200416 Domain constraints –all values appearing in a column of a relation must come from the same domain of values Domain definitions consist of –domain name –meaning –data type –size or length –allowable values or range of values Integrity Constraints

17 Monash University 200417 Entity integrity –no primary key attribute or component of primary key attribute can be null –ensures every relation has a primary key and all data values for that key are valid Null value –allowable when value is unknown or is not applicable –not a value or a zero, rather the absence of a value –inclusion in relational model is controversial – can lead to anomalies Integrity Constraints

18 Monash University 200418 Referential integrity –each foreign key value must match a primary key value in another relation, or the foreign key value must be null –associations between tables are defined using foreign keys –maintains consistency between rows in two relations –ensures every foreign key does correspond to an existing primary key in another relation else the foreign key is null Integrity Constraints

19 Monash University 200419 Well-Structured Relations A well-structured relation –is robust, stable and flexible –contains a minimum amount of redundancy –allows users to insert, modify, and delete rows in a table without errors or inconsistencies known as “anomalies”

20 Monash University 200420 Well-Structured Relations Three types of anomaly are possible -insertion -deletion -modification Relations that have been normalised to third normal form (3NF) are considered to be well structured relations –although even 3NF relations can have anomalies

21 Monash University 200421 Well-Structured Relations Insertion anomaly –cannot create a new record without supplying data values for for two independent data elements Deletion anomaly –cannot delete a record without losing related data in that record that might need to exist independently Modification anomaly –must sometimes update a data value in many records to ensure consistency

22 Monash University 200422 A Poorly-Structured Relation Can’t add new employee till completed course Delete emp no 150 and lose Delphi Name changes need to be made in more than one record Emp_IDEmp_NameCourseDate_Comp 100JimVB.Net2/4/03 100JimC++6/8/03 140JaneC++12/10/02 110WendyJava30/6/03 110WendyVB.Net2/4/03 150RobertDelphi1/5/04

23 Monash University 200423 Hoffer, J.A., Prescott, M.B. and McFadden, F.R., (2005), Modern Database Management, (7 th edn.), Pearson Education Inc., Upper Saddle River, NJ, USA. Ch. 5 References


Download ppt "Monash University 20041 Week 7 Data Modelling Relational Database Theory IMS1907 Database Systems."

Similar presentations


Ads by Google