Presentation is loading. Please wait.

Presentation is loading. Please wait.

©2005 The McGraw-Hill Companies, All rights reserved McGraw-Hill/Irwin

Similar presentations


Presentation on theme: "©2005 The McGraw-Hill Companies, All rights reserved McGraw-Hill/Irwin"— Presentation transcript:

1 ©2005 The McGraw-Hill Companies, All rights reserved McGraw-Hill/Irwin
McGraw-Hill/Irwin ©2005 The McGraw-Hill Companies, All rights reserved

2 Extended Learning Module C
DESIGNING DATABASES AND ENTITY-RELATIONSHIP DIAGRAMMING McGraw-Hill/Irwin ©2005 The McGraw-Hill Companies, All rights reserved

3 STUDENT LEARNING OUTCOMES
Identify how databases and spreadsheets are both similar and different List and describe the four steps in designing and building a relational database Define the concepts of entity class, instance, primary key, and foreign key

4 STUDENT LEARNING OUTCOMES
Given a small operating environment, build an entity-relationship (E-R) diagram List and describe the steps in normalization Describe the process of creating an intersection relation to remove a many-to-many relationship

5 INTRODUCTION Chapter 3 discussed why databases are important
This module teaches you how to design a relational database The relational database is the most popular model

6 INTRODUCTION Databases and spreadsheets are similar and different
Both have rows and columns of information in tables or worksheets Spreadsheet – you must know the physical row and column Databases – you work with information logically

7 INTRODUCTION Database – collection of information that you organize and access according to the logical structure of that information Relational database – uses a series of logically related two-dimensional tables or files to store information in the form of a database

8 DESIGNING & BUILDING A RELATIONAL DATABASE
Define entity classes & primary keys Define relationships among the classes Define information for each relation (relation = table = file) Use a data definition language to create the database

9 Remember Solomon Enterprises?
From Chapter 3 It provides concrete to commercial builders and individual home owners In Chapter 3, we looked at the customer relationship management side of Solomon’s database

10 Remember Solomon Enterprises?

11 Remember Solomon Enterprises?
Tables in Solomon’s database Customer Concrete Type Order Truck Employee Let’s continue with that example and expand to supply chain management (SCM)

12 Observations for Solomon
5 concrete types Home foundation and walkways Commercial foundation and infrastructure Premier speckled (with gravel) Premier marble Premier shell

13 Observations for Solomon

14 Observations for Solomon
6 raw materials Water Cement paste Sand Gravel Marble Shell Mixing instructions are for a cubic yard

15 Observations for Solomon
Some raw materials are in several concrete types A concrete type requires several raw materials Inventory (QOH) is tracked for all raw materials

16 Observations for Solomon
Suppliers provide raw materials Solomon uses only 1 supplier for a given raw material A supplier can provide several raw materials

17 Observations for Solomon
Water Supplier not tracked QOH not tracked

18 Business Rules for Solomon
A given concrete type will have many raw materials in it A given raw material may appear in many types of concrete Each raw material has one and only one supplier

19 Business Rules of Solomon
A supplier may provide many raw materials. There may be suppliers present not currently providing any raw materials These business rules are very important to remember

20 STEP 1: DEFINE ENTITY CLASSES AND PRIMARY KEYS
Entity class – concept – typically people, places, or things – about which you wish to store information and that you can identify with a unique key (called a primary key) Concrete Type Raw Material Supplier

21 STEP 1: DEFINE ENTITY CLASSES AND PRIMARY KEYS
Primary key – a field (or group of fields) that uniquely describes each record A record in a database is sometimes called an instance (of an entity class)

22 STEP 1: DEFINE ENTITY CLASSES AND PRIMARY KEYS
In general, stay away from names for primary keys (duplicates often exist) Concrete Type – Concrete Type Raw Material – Raw Material ID Supplier – Supplier ID Review Figure C.1 on page 162 to find examples of these

23 STEP 2: DEFINING RELATIONSHIPS AMONG ENTITY CLASSES
To define relationships, you create and use an E-R diagram Entity-relationship (E-R) diagram – a graphic method of representing entity classes and their relationships

24 E-R Diagrams Use 5 symbols Rectangle – entity class
Dotted line – relationship | - single relationship 0 – zero/optional relationship Crow’s foot ( ) – multiple relationship

25 E-R Diagrams

26 E-R Diagrams Figure C.2 on page 165 reads as…
A Concrete Type is composed of Raw Material A Raw Material is used to create a Concrete Type A Supplier provides a Raw Material A Raw Material is provided by a Supplier These statements match the business rules

27 E-R Diagrams - Cardinality
E-R diagrams show relationships They also denote the numerical nature of relationships This is called cardinality | - single relationship 0 – zero/optional relationship Crow’s foot ( ) – multiple relationship

28 E-R Diagrams - Cardinality
Following line marked A: A Supplier may not provide any Raw Material (0) but may provide more than one Raw Material ( )

29 E-R Diagrams - Cardinality
Following line marked B: A Raw Material must be provided by a Supplier (|) and can only be provided by one Supplier (|)

30 Normalization Normalization – process of assuring that a relational database structure can be implemented as a series of two-dimensional tables We will follow three rules of normalization

31 Normalization Rules Eliminate repeating groups or many-to-many relationships Assure that each field in a relation depends only on the primary key for that relation Remove all derived fields from the relations

32 Eliminating Many-To-Many Relationships
A many-to-many relationship exists in a relationship if there is a crow’s foot on each end You must eliminate these by creating an intersection or composite relation

33 Eliminating Many-To-Many Relationships

34 Eliminating Many-To-Many Relationships
Intersection (composite) relation – a relation you create to eliminate a many-to-many relationship Intersection relation will have a composite primary key Composite primary key – consists of the primary key fields from the two intersecting relations

35 Eliminating Many-To-Many Relationships

36 Solomon’s New Database Structure

37 Steps to Eliminate a Many-To-Many Relationship
Draw the part of the E-R diagram with the many-to-many relationship Write some primary keys for each relation Create a new E-R diagram with the intersection relation in the middle Write some composite primary keys for the intersection relation

38 Steps to Eliminate a Many-To-Many Relationship
Create a meaningful name for the intersection relation Move minimum cardinality appearing next to left relation to the right of the intersection relation Move minimum cardinality appearing next to right relation to the left of the intersection relation

39 Steps to Eliminate a Many-To-Many Relationship
Maximum cardinality on both sides of the intersection relation will always be many () General rule – the new minimum and maximum cardinalities for the 2 original relations will be one (|) and one (|)

40 STEP 3: DEFINING INFORMATION FOR EACH RELATION
To ensure that each field is in the right relation, ask the following question: “Does this piece of information depend only on the primary key for this relation?” Yes – it’s in the correct relation No – it’s in the wrong relation

41 STEP 3: DEFINING INFORMATION FOR EACH RELATION
See Figure C.6 on page 173 Look at the Raw Material relation Every field must depend on Raw Material ID Raw Material Name, QOH, and Supplier ID do Supplier Name does not

42 STEP 3: DEFINING INFORMATION FOR EACH RELATION
What does Supplier Name depend on? It depends on Supplier ID, the primary key for the Supplier relation Therefore, Supplier Name should appear in the Supplier relation and not the Raw Material relation All other fields are in the correct relations

43 STEP 3: DEFINING INFORMATION FOR EACH RELATION
View Figure C.6 again on page 173 Do you see any derived information? Derived information includes things like Counts Sums Average If you see any, remove them

44 STEP 3: DEFINING INFORMATION FOR EACH RELATION
Raw Material Total in the Concrete Type relation is derived It can be obtained by summing fields in the Bill of Material relation Therefore, you do not need Raw Material Total Take it out

45 STEP 3: DEFINING INFORMATION FOR EACH RELATION
View Figure C.7 on page 174 It is the correct and final structure There are no many-to-many relationships Each field depends only on the primary key for that relation There are no derived fields You have created a good database design

46 STEP 4: USE A DATA DEFINITION LANGUAGE TO CREATE YOUR DATABASE
You’re finally ready to implement your database with a DBMS Database management system (DBMS) – helps you specify the logical organization for a database and access and use the information within the database

47 STEP 4: USE A DATA DEFINITION LANGUAGE TO CREATE YOUR DATABASE
When using a data definition language, you will create the data dictionary Data dictionary – contains the logical structure for the information in a database This is the first step in implementing your database

48 STEP 4: USE A DATA DEFINITION LANGUAGE TO CREATE YOUR DATABASE
Extended Learning Module J is devoted to using Microsoft Access to Create the data dictionary for Solomon’s database Enter information into the database Create queries of information in the database Create reports of information in the database

49 CAN YOU… Identify how databases and spreadsheets are both similar and different List and describe the four steps in designing and building a relational database Define the concepts of entity class, instance, primary key, and foreign key

50 CAN YOU… Given a small operating environment, build an entity-relationship (E-R) diagram List and describe the steps in normalization Describe the process of creating an intersection relation to remove a many-to-many relationship

51 Extended Learning Module C
End of Extended Learning Module C McGraw-Hill/Irwin ©2005 The McGraw-Hill Companies, All rights reserved


Download ppt "©2005 The McGraw-Hill Companies, All rights reserved McGraw-Hill/Irwin"

Similar presentations


Ads by Google