Lesson 16 - curriculum.naf.orgcurriculum.naf.org/packaged/assets/downloads/technolog…  · Web...

14
AOIT Database Design Lesson 8 Entity-Relationship Models Student Resources Resource Description Student Resource 8.1 Notation: Entity-Relationship Model Student Resource 8.2 Entity-Relationship Diagram: Foreign Keys Student Resource 8.3 Assignment Sheet: Creating an Entity-Relationship Model Student Resource 8.4 Assignment Sheet: Validating an Entity-Relationship Model Student Resource 8.5 Worksheet: Data Types Copyright © 2009–2014 NAF. All rights reserved.

Transcript of Lesson 16 - curriculum.naf.orgcurriculum.naf.org/packaged/assets/downloads/technolog…  · Web...

Page 1: Lesson 16 - curriculum.naf.orgcurriculum.naf.org/packaged/assets/downloads/technolog…  · Web viewNotation: Entity-Relationship Model. Student Name:_____ Date:_____ Directions:

AOIT Database Design

Lesson 8Entity-Relationship Models

Student Resources

Resource Description

Student Resource 8.1 Notation: Entity-Relationship Model

Student Resource 8.2 Entity-Relationship Diagram: Foreign Keys

Student Resource 8.3 Assignment Sheet: Creating an Entity-Relationship Model

Student Resource 8.4 Assignment Sheet: Validating an Entity-Relationship Model

Student Resource 8.5 Worksheet: Data Types

Copyright © 2009–2014 NAF. All rights reserved.

Page 2: Lesson 16 - curriculum.naf.orgcurriculum.naf.org/packaged/assets/downloads/technolog…  · Web viewNotation: Entity-Relationship Model. Student Name:_____ Date:_____ Directions:

AOIT Database DesignLesson 8 Entity-Relationship Models

Student Resource 8.1

Notation: Entity-Relationship ModelStudent Name:_______________________________________________________ Date:___________

Directions: Follow your teacher's instructions to work through the steps of this worksheet.

Part 1Fill in the blank cells in the following table as your teacher explains the different types of relationships.

Name of Relationship Type

Description Standard Notation

One-to-one1:1

Relates one instance of one entity to multiple instances of another entity

N:M

Maximum cardinality is the maximum number of instances of an entity on each side of a relationship.

Part 2Answer the following questions in preparation for setting up some relationships about drivers:

1. How many driver’s licenses can one driver have? (For this exercise, let’s say the answer to this question is: A driver can have only one license.)

2. How many drivers can one license belong to?

3. Does a license have to belong to a driver, or can it exist without a driver?

4. How many tickets can one driver get?

5. How many drivers can one ticket belong to?

Copyright © 2009–2014 NAF. All rights reserved.

Page 3: Lesson 16 - curriculum.naf.orgcurriculum.naf.org/packaged/assets/downloads/technolog…  · Web viewNotation: Entity-Relationship Model. Student Name:_____ Date:_____ Directions:

AOIT Database DesignLesson 8 Entity-Relationship Models

6. How many routes can one driver take?

7. How many drivers can take the same route?

Part 3Using what you know about relationships as well as your answers to the preceding questions, put the standard notation for each relationship in the diamond box.

Part 4Write a sentence under each of the above diagrams explaining the relationship. For example, the first diagram might look like this:

A driver can have only one license, and a license can belong to only one driver.

Copyright © 2009–2014 NAF. All rights reserved.

Page 4: Lesson 16 - curriculum.naf.orgcurriculum.naf.org/packaged/assets/downloads/technolog…  · Web viewNotation: Entity-Relationship Model. Student Name:_____ Date:_____ Directions:

AOIT Database DesignLesson 8 Entity-Relationship Models

Part 5Define the maximum and minimum cardinality in the following relationships. (Put the maximum cardinality notation in the diamond; put the minimum cardinality numbers on either side of the diamond, as shown in the first example.) Write a phrase above and below the diagram to explain each side of the minimum cardinality, as shown in the first example.

Copyright © 2009–2014 NAF. All rights reserved.

Page 5: Lesson 16 - curriculum.naf.orgcurriculum.naf.org/packaged/assets/downloads/technolog…  · Web viewNotation: Entity-Relationship Model. Student Name:_____ Date:_____ Directions:

AOIT Database DesignLesson 8 Entity-Relationship Models

Student Resource 8.2

Entity-Relationship Diagram: Foreign KeysStudent Name:_______________________________________________________ Date:___________

Directions: The tables below show all of the entities from the dolphin database with their attributes and primary keys. First, draw lines between the entities that are related. Then, where relevant, create a foreign key by copying the primary key attribute from one entity onto the entity it points to. Finally, work with your partner to create pointers and label foreign keys for the other entities on the worksheet. Consider the blank cells in some of the tables as a clue to where foreign keys might go. Remember that for entities that have composite primary keys, part of the primary key may also

Copyright © 2009–2014 NAF. All rights reserved.

Page 6: Lesson 16 - curriculum.naf.orgcurriculum.naf.org/packaged/assets/downloads/technolog…  · Web viewNotation: Entity-Relationship Model. Student Name:_____ Date:_____ Directions:

AOIT Database DesignLesson 8 Entity-Relationship Models

serve as a foreign key. Be sure that you can explain each of the foreign keys you create.

Copyright © 2009–2014 NAF. All rights reserved.

Page 7: Lesson 16 - curriculum.naf.orgcurriculum.naf.org/packaged/assets/downloads/technolog…  · Web viewNotation: Entity-Relationship Model. Student Name:_____ Date:_____ Directions:

AOIT Database DesignLesson 8 Entity-Relationship Models

Student Resource 8.3

Assignment Sheet: Creating an Entity-Relationship Model

Student Names:_______________________________________________________ Date:___________

Directions: Working with your culminating project group, follow the steps below to create an entity-relationship model of your database. To begin, take notes as your teacher explains each step. Review the assessment criteria before you start work. After you create your model, follow the instructions in Student Resource 8.4, Assignment Sheet: Validating an Entity-Relationship Model, to validate it.

1. Take out the tables that you created for your culminating project in Lesson 6. All of the entities are normalized to third normal form.

2. Work as a group to determine which entities have relationships with each other. When you determine there is a relationship, write a textual description of what’s going on in the relationship.

3. Using the software package that your teacher has taught you to use for drawing entity-relationship models, draw a model of your entities, and indicate the relationships between entities.

4. Below the lines that indicate relationships, write your textual description of what’s going on in each relationship.

5. Define the cardinality of the relationships, and indicate this on the diagram.

6. Define pointers from one entity to another, and use foreign keys to identify them. (Note that some software packages automatically insert foreign keys.)

Make sure your assignment meets or exceeds the following assessment criteria: The relationships between entities are correct, and the whole model makes sense.

The textual descriptions accurately describe the relationships.

Cardinality is indicated correctly.

The pointers and foreign key names are correct.

The model is visually clear, spatially well organized, and easy to follow.

Copyright © 2009–2014 NAF. All rights reserved.

Page 8: Lesson 16 - curriculum.naf.orgcurriculum.naf.org/packaged/assets/downloads/technolog…  · Web viewNotation: Entity-Relationship Model. Student Name:_____ Date:_____ Directions:

AOIT Database DesignLesson 8 Entity-Relationship Models

Student Resource 8.4

Assignment Sheet: Validating an Entity-Relationship Model

Directions: This validation process helps to ensure that your model is correct. Go through this validation and make any necessary changes before submitting your entity-relationship model for assessment.

1. Print a copy of your entity-relationship model for each group member.

2. Using data from your culminating project client, have each group member take one set of data (for example, the data from one invoice or the data for one customer order) so that you can use this data to create instances of each entity in your model.

3. On your printed model, write the information for your instances next to each attribute. See the example on the next page for an idea of what your model will look like. (You may have to try writing small but still legibly!) You may not have information for all of the attributes, and you may have more than one instance of some of the entities. Indicate any artificial attributes that you think you will need to create in order to have the primary and foreign keys you need.

4. Using the information from your instances, write down a description of all the pointers from one entity to another, and explain the cardinality. See the example on the next page to get an idea of what kinds of descriptions you should write.

5. After all group members have finished their descriptions, explain the relationships you have documented to the other members of your group. Ask questions if there is anything that doesn’t make sense to you. This is how you discover problems in the model or find ways that the model doesn’t work for the data that you need to enter into the model.

6. Make any needed changes to the model based on what you discover.

Copyright © 2009–2014 NAF. All rights reserved.

Page 9: Lesson 16 - curriculum.naf.orgcurriculum.naf.org/packaged/assets/downloads/technolog…  · Web viewNotation: Entity-Relationship Model. Student Name:_____ Date:_____ Directions:

AOIT Database DesignLesson 8 Entity-Relationship Models

Example of Entities with Instances

Text Describing Relationships On the Customers table, Customer ID 478 (Customer Name Joe Vanden), points to Order ID

BK678 in the Orders table. This customer Order ID points to one and only one Orders table.

The Orders table indicates that this order will be shipped to Joe by Shipper ID 974. The Shippers table shows that this Shipper ID belongs to the Blue Lines shipper. The order has one and only one shipper.

The Order ID in the Orders table points to two Order Details that have this Order ID. The first Order Details instance with this Order ID shows a Product ID of 478. In the Products table, the Product ID 478 indicates the product is a dolphin necklace. The second Order Details instance with this Order ID shows a Product ID of 510. In the Products table, the Product ID 510 indicates the product is a dolphin T-shirt. The order includes two products, and there are separate instances of Order Details for each product included in the order.

The Products table shows a Supplier ID of DD67 for Product ID 478 and for Product ID 510. Both products come from the same supplier. The Suppliers table indicates that this Supplier ID belongs to Dolphin Delights. This is the company that supplies the dolphin necklace and the dolphin T-shirt.

The Products table shows a Category ID of 4 for Product ID 478. The Categories table shows that Category 4 is for jewelry. The Products table shows a Category ID of 3 for Product ID 510. The Categories table shows that Category 3 is for clothing.

Copyright © 2009–2014 NAF. All rights reserved.

Page 10: Lesson 16 - curriculum.naf.orgcurriculum.naf.org/packaged/assets/downloads/technolog…  · Web viewNotation: Entity-Relationship Model. Student Name:_____ Date:_____ Directions:

AOIT Database DesignLesson 8 Entity-Relationship Models

Student Resource 8.5

Worksheet: Data TypesStudent Name:_______________________________________________________ Date:___________

Directions: Specify a data type for each attribute in the tables below. The list of data types shows all of the data types available in Microsoft Access.

There are 10 different data types available in Access:

AutoNumber: Numbers that are automatically generated for each record.

Text: Short, alphanumeric values, such as a last name or a street address.

Currency: Monetary values.

Date/Time: Dates and times.

Hyperlink: Hyperlinks, such as email addresses.

Memo: Long blocks of text and text that uses text formatting, such as a product description.

Number: Numeric values, such as distances.

Yes/No: Values that can be expressed as either a Yes answer or a No answer.

OLE Object: OLE objects, such as Word documents.

Attachment: Files, such as digital photos. Multiple files can be attached per record.

Products

Attribute Item ID Product Name

Item Description Supplier Category Supplier

NumberPurchase Price

Units in Stock

Units on Order

Data Type

Orders

Attribute Order ID Customer ID Order Date Shipped Date Shipper Overnight? Ship Cost

Data Type

Copyright © 2009–2014 NAF. All rights reserved.