Complete Solved Problems in Erd
Complete Solved Problems in Erd
(d) Doctors prescribe drugs for patients. A doctor can prescribe one or
more drugs for a patient and a patient can get one or more prescriptions,
but a prescription is written by only one doctor.
Solution:
PHARMACEUTICAL
Entities: _ COMPANY DRUG
Relationship type and cardinality: one to many 1:M between
pharmaceutical company and drug
PHARMACEUTICAL manufactures M
1 DRUG
_ COMPANY
(1,N) (1,1)
PHARMACY
Entities: DRUG
1 M M 1
PHAR_DRUG DRUG
PHARMACY (1,M) (1,1) (1,1) (0,M)
DRUG
Entities: PRESCRIPTION
PATIENT
1
Written for
PATIENT
(1,M)
(d) Doctors prescribe drugs for patients. A doctor can prescribe one or
more drugs for a patient and a patient can get one or more
prescriptions, but a prescription is written by only one doctor.
1 M
DOCTOR Writes
(1,M) (1,1) PRESCRIPTION
1 M M 1
PHARMCEUTICAL_C CONTRACT PHARMACY
OMPANY (0,M) (1,1) (1,1) (0,M)
PK PRESCRIPTION_ID PHYS_FIRST_NAME
PHYS_LAST_NAME
DOCTOR PRESCRIPTION_DATE
(1,M) (1,1) PRESC_TOTAL
PK DOCTOR_ID
FK1 DOCTOR_ID
(1,1)
DOCTOR_NAME FK2 PATIENT_ID (1,M)
FK3 PHYSICIAN_ID PATIENT
DOCTOR_TEL
(1,M) PK PATIENT_ID
PATIENT_NAME
(1,1) PATIENT_TEL
PRESCRIPTION_DRUG
PHARMACEUTICAL_CO
PK,FK1 PRESCRIPTION_ID
PK PHARMA_CO_ID PK,FK2 DRUG_CODE
DRUG_PHARMACY
PHARMA_CO_NAME
PHARMA_CO_ADDRESS PK,FK1 DRUG_CODE (1,1)
(1,1)
PHARMA_CO_FAX PK,FK2 PHARMACY_ID
PHARMA_CO_P.O. (0,M)
PHARMA_CO_TEL (1,M) (1,1) ON_HAND (1,M)
PHARMA_CO_EMAIL DRUG
(1,1) PHARMACY
PK DRUG_CODE
(0,M) (0,M)
PK PHARMACY_ID
DRUG_DESCRIPTION
DRUG-TRADEMARK PHARMACY_ADDRESS
FK1 PHARMA_CO_ID PHARMACY_TEL
PHARMACY_P.O.
PHARMACY_FAX
PHARMACY_EMAIL
CONTRACT
PK CONTRACT_ID (0,M)
(1,1) PK,FK1 PHARMA_CO_ID (1,1)
PK,FK2 PHARMACY_ID
CONTRACT_PERIOD
START _DATE
Problem # 2: The ACME Machine Shop is a small job shop that does
machining of components for that assembled finished products. The
customers give ACME engineering drawings of parts and request
production of parts from ACME as needed. The manager of the machine
shop has used a database to try to organize some basic information on the
customers’ parts and their machining requirements as well as scheduling
information based on orders. The tables and their design requirements are
shown here. The meaning of the tables is as follows:
SOLUTION
3.4 Bikes-R-Us sells standard and customized bicycles over the Web. The company
buys components from various vendors in its supply chain and assembles the
components into bicycles. Standard bicycles are produced to inventory, while custom
bicycles are only made to order. Bikes-R-Us wants to develop a database for certain
parts of its business. The company needs an E-R diagram to use as a basis for a
database design. Develop the E-R diagram from the following statements:
(a) Bikes-R-Us will keep track of materials. The materials are of two kinds:
components and bikes.
(b) Materials are related to each other by their bill of material structure. Each bike
requires M components. Each component may go into 1 or more bikes.
(c) Components are provided by vendors. A component must be ordered from one or
more vendors. A vendor must provide one or more components.
(d) Inventoried material is known as a “material lot.” A lot is a grouping of the same
material either supplied by the same vendor (components) on a particular shipment or
produced in
the same production run (bikes).
(e) A material lot may be provided by a vendor. When a material lot is provided by a
vendor, it is associated with one and only one vendor. A vendor may have provided
zero, one, or many material lots. Some material lots (e.g., bikes) are not provided by
vendors.
(f) A warehouse location is a place where a material lot is stored. A material lot may
be stored in more than one location. A warehouse location may have zero, one, or
many material lots.
(g) A material lot may be produced on an assembly line. Each assembly line is
associated with one or more material lots. Some material lots (e.g., components) are
not produced on an assembly line.
(h) An assembly line is composed of stations. Each assembly line has one or more
stations, and each station is associated with exactly one assembly line.
(i) An assembly process plan describes the steps by which a bike is assembled. Each
bike has one assembly process plan, but the same assembly process plan may be used
by more than one bike.
(j) Each assembly process plan has several steps. A step is associated with one
process plan.
(k) Each process plan step is associated with a station, where that step is executed.
Each step is associated with one and only one station. However, a station may be used
in many process plan steps.
b) The following is a list of attributes. Assign each attribute to the appropriate entities. If a
composite entity has to be introduced in order to assign an attribute, name that composite
entity. Indicate which attributes are key attributes.
STYLE_ID — A unique identifier of a style of pants
STYLE_DESCRIPTION — A description of a style (e.g., “Loose Fit Denim,” or “Pleated
Cuffed Pants”)
CUST_ID — Unique identifier of a customer of Pants-R-Us
CUST_NAME — The name of the company that is the customer
CUST_ADDRESS — The address of the company that is the customer
STORE_ID — The identifier of the customer’s store as provided by the customer
STORE_ADDRESS — The address of the store
COLOR_ID — Unique identifier of a color
COLOR_DESC — Description of a color (e.g., navy, indigo, stone)
UPC — Universal product code, which is a unique identifier of an SKU
WAIST — The waist dimension of an SKU
LENGTH — The length dimension of an SKU
Pants-R-Us will receive actual point-of-sales data by SKU from the customers’ stores and
keeps track of the stores’ inventory positions.
STD_SALES — Customer sales to date from the store location
STD_RETURNS — Cumulative returns to date from the store
ON_HAND — The amount of On_Hand units of inventory of an SKU in a store
IN_TRANSIT — The number of units of inventory of an SKU that has been shipped to a
store but not yet received
ON_ORDER — The number of units of an SKU ordered by a store but not yet shipped
SOLUTION