Top Banner
Objectives for Week (1/29 & 1/31) Know how to read, understand, and create a database model using a modeling tool - ERD’s. Know the process of completing a database design. Understand the structure and limitations of the relational model. Know how to identify and differentiate the required components of a database design. 1
14

Objectives for Week (1/29 & 1/31) Know how to read, understand, and create a database model using a modeling tool - ERD’s. Know the process of completing.

Dec 28, 2015

Download

Documents

Flora Kelly
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Objectives for Week (1/29 & 1/31)  Know how to read, understand, and create a database model using a modeling tool - ERD’s.  Know the process of completing.

Objectives for Week (1/29 & 1/31)

Know how to read, understand, and create a database model using a modeling tool - ERD’s.

Know the process of completing a database design.

Understand the structure and limitations of the relational model.

Know how to identify and differentiate the required components of a database design.

1

Page 2: Objectives for Week (1/29 & 1/31)  Know how to read, understand, and create a database model using a modeling tool - ERD’s.  Know the process of completing.

2

Order

PK orderID

orderdateFK1 customerID

Customer

PK customerID

name telephone email

OrderLine

PK,FK1 orderIDPK,FK2 itemID

quantity price

Item

PK itemID

description unitcost

placesIs

placed by

contains

Is related to

Is related to

Is on

Visualization Method: Data Model (Blueprint)

This ERD is referred to as a “logical” ERD

Page 3: Objectives for Week (1/29 & 1/31)  Know how to read, understand, and create a database model using a modeling tool - ERD’s.  Know the process of completing.

3

Vocabulary about entities

Entity: Person, place or thing about which we want to store data. Should be a noun.

Entity instance: One row in an entity. In a customer entity, one customer such as “Joe’s Diner” is an entity instance.

Strong entity: An entity that contains data we want to store regardless of its relationship to other data. Examples?

Weak entity: An entity that doesn’t exist unless it is related to other entities. Examples?

Page 4: Objectives for Week (1/29 & 1/31)  Know how to read, understand, and create a database model using a modeling tool - ERD’s.  Know the process of completing.

4

Vocabulary about keys

One of the rules about a relational database is that each entity must have a primary key.

Primary key: One or more attributes that has/have a unique value in each entity instance.

Concatenated primary key: More than one attribute required for the primary key.

Natural primary key: Can be created from existing attributes.

Surrogate primary key: Is created by the database designer.

Page 5: Objectives for Week (1/29 & 1/31)  Know how to read, understand, and create a database model using a modeling tool - ERD’s.  Know the process of completing.

5

Vocabulary about relationships

Relationship: A business rule connection between entities. A relationship is a verb.

Bi-Directional: All data relationships can be read both ways.

Cardinality: describes the minimum and maximum number of instances that one entity has with another entity in a relationship.

Foreign Key: Each relationship requires a foreign key. The primary key of one table is added to another table to link the two tables together. A concatenated primary key yields a concatenated foreign key.

Page 6: Objectives for Week (1/29 & 1/31)  Know how to read, understand, and create a database model using a modeling tool - ERD’s.  Know the process of completing.

6

Page 7: Objectives for Week (1/29 & 1/31)  Know how to read, understand, and create a database model using a modeling tool - ERD’s.  Know the process of completing.

7

 1a. What is the purpose of the DoesBusinessIn entity? What data might be stored in that entity?

1b. What would be an appropriate primary key for the DoesBusinessIn entity?

1c. Is the DoesBusinessIn entity strong or weak? Why?

1d. Identify a composite attribute on the data model. What are the meaningful parts of that attribute?

Page 8: Objectives for Week (1/29 & 1/31)  Know how to read, understand, and create a database model using a modeling tool - ERD’s.  Know the process of completing.

8

Page 9: Objectives for Week (1/29 & 1/31)  Know how to read, understand, and create a database model using a modeling tool - ERD’s.  Know the process of completing.

9

1e. Where is a unary relationship on the data model? Explain the meaning of the relationship. Describe how the cardinalities of the relationship might differ for different organizations.

Page 10: Objectives for Week (1/29 & 1/31)  Know how to read, understand, and create a database model using a modeling tool - ERD’s.  Know the process of completing.

10

1f. Explain in words the relationship between the entities Vendor, Supplies, and RawMaterial. In what way might Pine Valley change the way it does business that would cause the Supplies entity to be eliminated?

Page 11: Objectives for Week (1/29 & 1/31)  Know how to read, understand, and create a database model using a modeling tool - ERD’s.  Know the process of completing.

11

ERD 2a

A corporation owns a series of shopping malls. Each shopping mall has similar stores (examples are: Footlocker, Walking Company, Jones New York, Abercrombie and Fitch) but each store is physically different at each mall. Each shopping mall is identified by a MallID. For each shopping mall, we want to keep track of the name of the mall, the address, zip code, and main telephone number. Each store is identified by a StoreID. For each store, we want to keep track of the name of the store and a long description of the type of the store. The corporation needs to associate a given store with a given shopping mall. For a given store at a given shopping mall, the corporation wants to keep track of the date the store opened at the mall, the name of the manager for the store, and the telephone number for that specific store in that specific mall.

Page 12: Objectives for Week (1/29 & 1/31)  Know how to read, understand, and create a database model using a modeling tool - ERD’s.  Know the process of completing.

12

MallID

Mall Name

Mall Address

Mall Zip

Code

Mall Phone #

StoreID

Store Name

Store Description

Date Open

ed

Manager Name

Store Phon

e

123 Gilroy Outlets

123 Garlic Street, Gilroy, CA

90456 800-233-4929

1793 Jones New York

Women's professional attire, mid-range

9/12/1995

Joanne Brown

560-493-4403

123 Gilroy Outlets

123 Garlic Street, Gilroy, CA

90456 800-233-4929

5644 FootLocker Athletic Shoes, Men, Women, Family

8/16/1998

Bill Targenson

560-495-3939

123 Gilroy Outlets

123 Garlic Street, Gilroy, CA

90456 800-233-4929

6781 New York and Company

Women's casual attire, bargain

3/15/2005

Ahmad Cedersill

560-667-3341

677 Sacramento Outlets

8922 Oak Street, Roseville, CA

93201 450-223-9392

1793 Jones New York

Women's professional attire, mid-range

4/16/2006

Willie Masters

890-451-5861

Page 13: Objectives for Week (1/29 & 1/31)  Know how to read, understand, and create a database model using a modeling tool - ERD’s.  Know the process of completing.

13

ERD 2b

A student, identified by a studentID, can participate in zero or many campus-based organizations. Each organization is identified by an organizationID and we store the original date the organization was started on campus, as well as the name of the organization in the data. Each organization may have multiple students participating in that organization. For each student we store his or her name, address, and telephone number. For each student who participates in an organization, we want to store the date that the student started participating in that organization, and an attribute that indicates whether or not the student is willing to be an officer for the organization. There is only one start date per student per organization (in other words, we don’t care whether a student quits an organization and rejoins – we are going to store only one start date per student per organization).

Page 14: Objectives for Week (1/29 & 1/31)  Know how to read, understand, and create a database model using a modeling tool - ERD’s.  Know the process of completing.

14

ERD 2cYou have been asked to design a database for a single hospital. The hospital wants to keep track of data about patients. The hospital wants to keep track of patient admittance, as well as patient treatment by health care professionals. Patients are admitted to the hospital by physicians, but physicians are only one kind of health care professional (HCPROF) at the hospital. Assume that the hospital has a large number of HCPROF’s, but they don’t need to differentiate between physicians and other types of HCPROF’s. Attributes of HCPROF include HCPROFID (identifier), type, and specialty. The hospital wants to keep track of the date a patient was admitted and also the admitting HCPROF. It is possible that a patient may be admitted to the hospital more than once. This is an example of “time stamping” data so that the data can be maintained over time. The hospital wants to keep the patients on file with the assumption that the patient may be admitted more than once and the hospital needs to know each different date that a patient was admitted. Attributes of PATIENT include patient_id (identifier) and patient_name. Any individual patient who is admitted must have exactly one admitting HCPROF, but an HCPROF may admit no patients or many patients. Once admitted, a given patient may be treated by no HCPROF’s, but could be treated by multiple HCPROFs. The particular HCPROF who admits a given patient may or may not treat that same patient. A particular HCPROF may treat any number of patients, or may not treat any patients. Whenever a patient is treated, the hospital records the details of the treatment (TREATMENTDETAIL). Attributes of TREATMENTDETAIL include date, time, and outcome. It is possible that more than one HCPROF participates in the same TREATMENTDETAIL for a patient. The hospital wants to keep track of all HCPROF’s who participate in a treatment. For each HCPROF who participates in a TREATMENTDETAIL, the hospital wants to record the notes from the HCPROF and the amount of time that the HCPROF spent on the treatment. For example, if three HCPROF’s participate in a single TREATMENTDETAIL for a single patient, the hospital wants to keep track of the notes and time spent for each of the three HCPROF’s.