Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSIS 115 Database Design and Applications for Business

Similar presentations


Presentation on theme: "CSIS 115 Database Design and Applications for Business"— Presentation transcript:

1 CSIS 115 Database Design and Applications for Business
Dr. Meg Fryling “Dr. Meg” Fall 2012 @SienaDrMeg #csis115

2 Agenda Homework (see next slide)
Chapter 6: Translating ER Diagrams to Relations Conceptual design to physical database

3 Homework See Course Schedule for Readings Project – Part II (Rewrite)
Due Weds, 10/31 by start of class Updated ER Diagram and any needed changes to description Midterm is Mon, 11/5 Will discuss format as we get closer May bring a “cheat sheet” 8.5x11, handwritten, both sides, must use your own!

4 FYI - Improve data entry by adding a lookup
Try it! Add lookup so the only values that can be selected for company county are: Schenectady Albany Hamilton

5 The ideal primary key is _____.
A) short B) numeric C) fixed D) A and B E) A, B and C Answer: E

6 A surrogate key should be considered when ________.
A) a relationship is M:N B) a composite key is required C) the key contains a lengthy text field D) the key contains a value that will change frequently D) the key contains a number Answer: C & D are best answers but B is a good answer too, particularly if the composite key contains more than 3-4 fields

7 Which of the following is not true about surrogate keys?
A) They are identifiers that are supplied by the system, not the users. B) In Access, their data type is always Autonumber. C) They are nonunique within a table. D) The DBMS will not allow their values to be changed. Answer: C

8 Surrogate Keys

9 In a relational database design, all relationships are expressed by ________.
A) creating a primary key B) creating a foreign key C) creating a supertype D) creating a surrogate key E) creating a line between entities Answer: B For weak ID-dependent entities, the foreign key is part of the primary key.

10 When representing a 1:1 relationship in a relational database design ________.
A) the key of each table must be placed as foreign keys into the other B) the key of either table may be placed as a foreign key into the other C) the key of both tables must be the same D) the intersection table gets the key from both relations E) B and C Answer: B As for C – The key of both tables could be the same but it is not required.

11 Which of the following is required to implement a 1:1 relationship?
Set foreign key to required Index foreign key and allow duplicates Index foreign key and do not allow duplicates Make foreign key the primary key as well No can do! Answer: Both C and D will work

12 A) incremental updates B) incremental deletes
A referential integrity constraint policy that insures that foreign key values in a table are correctly maintained when there is a change to the primary key value in the parent table is called ________. A) incremental updates B) incremental deletes C) controlled key adjustments D) cascading updates E) cascading deletes Answer: D

13 Referential Integrity
Select for all relationships to maintain integrity of your data Prevents orphan child records Prevents entry of invalid values Prohibit PK updates of parent OR cascade updates No need with surrogate keys Prohibit delete of parents (with child records) OR cascade deletes Only cascade deletes on weak entities! Prevents orphan child records (e.g. Won’t let me delete a Department if there are associated employees) Prevents entry of invalid values (e.g. Associate employee with department that doesn’t exist in department table)

14 Which of these should I select?

15 WARNING: Must be same data type or you can’t enforce referential integrity

16 But remember… Foreign keys can never be autonumbers!!
If mapping to an autonumber primary key, select number data type.

17 What’s wrong here? All fields in PK of patient must be FK in visit. The primary key of PATIENT should really just be PatientID.

18 Let’s Try It! Open the HR Database from Blackboard (In-class activity 5) This is not the same one you were creating! HumanResourcesDB.accdb Create relationship below

19 To represent a one-to-many relationship in a relational database design ________.
A) the key of the child is placed as a foreign key into the parent B) the key of the parent is placed as a foreign key into the child C) an intersection table must be created D) the key of the table on the "many" side is placed in the table on the "one" side E) the keys of both tables are joined into a composite key Answer: B

20 Create Relationships: 1:N Strong Entity Relationships
KROENKE AND AUER - DATABASE PROCESSING, 11th Edition © 2010 Pearson Prentice Hall

21 Let’s Try It! Back to HR Database
Create a one-to-many “has-departments” relationship between COMPANY and DEPARTMENT

22 Relationships Using ID-Dependent Entities: Association Relationships
QUOTATION (CompanyName, PartNumber, Price) KROENKE AND AUER - DATABASE PROCESSING, 11th Edition © 2010 Pearson Prentice Hall

23 Relationships Using ID-Dependent Entities: Multivalued Attributes
As a data model As a database design KROENKE AND AUER - DATABASE PROCESSING, 11th Edition © 2010 Pearson Prentice Hall

24 Let’s Try It! Back to HR Database
Create a one-to-many “has-contacts” relationship between COMPANY and PHONE_CONTACT


Download ppt "CSIS 115 Database Design and Applications for Business"

Similar presentations


Ads by Google