Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter Six Professor Adams’ Slides. Note that entities are shadowed, tables are not. Note that entities have no physical existence (blueprint) Note.

Similar presentations


Presentation on theme: "Chapter Six Professor Adams’ Slides. Note that entities are shadowed, tables are not. Note that entities have no physical existence (blueprint) Note."— Presentation transcript:

1 Chapter Six Professor Adams’ Slides

2

3 Note that entities are shadowed, tables are not. Note that entities have no physical existence (blueprint) Note the use of the key symbol to indicate the primary key

4 Surrogate Keys A surrogate key is a DBMS-supplied identifier of each row in a table Surrogate keys are unique and they never change Surrogate keys are assigned when row is created and destroyed when row is deleted. Surrogate key values are “the best” primary keys because they are designed to be short, numeric, and fixed They are necessary when there is not obvious primary key, or when the rows are not unique.

5 Surrogate Key Disadvantages Their values have no meaning to the user Another disadvantage arises when data are shared among different databases. (see description of problems on page 173)

6 Candidate (alternate) keys There is no difference between the terms candidate key and alternate key The image shows a notation for specifying alternate keys.

7 Column Properties – Null Status Null status –Can a column have a null value or not –Null means null values are allowed (not that values are null) –See (BTW) on p. 175 Data type Default value Data Constraints

8 Column Properties – data type Null status Data type –Each DBMS has different data types money vs currency date vs datetime –Some SQL Server data types –Generic specifications CHAR(n), VARCHAR(n), DATE, TIME, MONEY, INTEGER,DECIMAL Default value Data Constraints

9 Specify Column Properties: SQL Server Data Types

10 Specify Column Properties: Oracle Data Types

11 Column Properties – Default value Null status Data type Default value –A default value is a value supplied by the DBMS when a new row is created. –constant, string, function result –May be supplied by a trigger Data Constraints

12 Column Properties – Data constraints Null status Data type Default value Data Constraints –Domain constraints Limit column values to a particular set of values –Range constraints Limit values to a particular interval of values –Interrelation constraints Limit a column’s values in comparison with other columns in the same or other tables

13 Verify Normalization Are the tables in Boyce-Codd normal form? –Is every determinant in every relation a candidate key? –Does every determinant uniquely determine a row? Have all multi-valued dependencies been removed? –Is there still a condition in any relation with three or more attributes in which independent attributes appear to have relationship they do not have?

14 Relationships Strong Relationships 1:1 1:N N:M ID-Dependent Entities Mixed Entity Relationships Subtype Relationships Recursive Relationships 1:1 1:N N:M Ternary & Higher Order Relationships

15 1:1 Strong Entity Relationships Place the key of one entity in the other entity as a foreign key: –Either design will work – no parent, no child –Minimum cardinality considerations may be important: O-M will require a different design that M-O, and One design will be very preferable

16 Choice we made ClubMember(MemberNumber, email, phone, LockerNumber) Locker(LockerNumber, LockerRoom, LockerSize)

17 1:N Strong Entity Relationships Place the primary key of the table on the one side of the relationship into the table on the many side of the relationship as the foreign key (foreign key doesn’t have to be unique) The one side is the parent table and the many side is the child table, so “Place the key of the parent in the child”

18 N:M Strong Entity Relationships In an N:M strong entity relationship there is no place for the foreign key in either table: –A COMPANY may supply many PARTs –A PART may be supplied by many COMPANYs

19 N:M Strong Entity Relationships Create an intersection table


Download ppt "Chapter Six Professor Adams’ Slides. Note that entities are shadowed, tables are not. Note that entities have no physical existence (blueprint) Note."

Similar presentations


Ads by Google