Assignment 4 Fundamental of Data Base
Assignment 4 Fundamental of Data Base
Problem 15. (25 points) Write the business rules that are reflected in the ERD shown in Figure P2.15.
(Note that the ERD reflects some simplifying assumptions. For example, each book is written by only one
author. Also, remember that the ERD is always read from the "1" to the "M" side, regardless of the
orientation of the ERD components.)
Entities — There are four entities in the above ERD namely PUBLISHER, BOOK and
Relationships — The various relationships between the entities are the following:
*PUBLISHER and BOOK :Between the PUBLISHER and BOOK entities, there is a 1: M
relationship. This is because a PUBLISHER can publish many BOOK but each BOOK must be
published by a Singe PUBLISHER.
*BOOK and AUTHOR: Between the BOOK and AUTHOR entities, there is a 1: M relationship. This
is because an AUTHOR can write many BOOK but each BOOK must be written by a single
AUTHOR.
*AUTHOR and CONTARCT :Between the AUTHOR and CONTRACT entities, there is a 1: M
relationship. This is because an AUTHOR can sign many CONTRACT but each CONTRACT must
be signed only a Single AUTHOR.
*CONTRACT and PUBLISHER: Between the CONTRACT and PUBLISHER entities, there is a 1: M
relationship.This is because a PUBLISHER can submit many CONTRACT but each CONTRACT
must be submitted by a single PUBLISHER.
Problem 16. (25 points)
Create a Crow's Foot ERD for each of the following descriptions. (Note that the word many merely
means more than one in the database modeling environment.)
a. Each of the MegaCo Corporation's divisions is composed of many departments. Each department has
many employees assigned to it, but each employee works for only one department. Each department is
managed by one employee, and each of those managers can manage only one department at a time.
b. During some period of time, a customer can download many ebooks from BooksOnline. Each of the
ebooks can be downloaded by many customers during that period of time.
d. The KwikTite Corporation operates many factories. Each factory is located in a region, and each region
can be "home" to many of KwikTite's factories. Each factory has many employees, but each employee is
employed by only one factory.
e. An employee may have earned many degrees, and each degree may have been earned by many
employees.
SQL PART
1. Modify the following SQL command so that the Rep_ID column is the PRIMARY KEY for the table and
the default value of Y is assigned to the Comm column. (The Comm column indicates whether the sales
representative earns commission.)
2. Change the STORE_REPS table so that NULL values can’t be entered in the name columns (First and
Last).
3. Change the STORE_REPS table so that only a Y or N can be entered in the Comm column.
4. Add a column named Base_salary with a datatype of NUMBER(7,2) to the STORE_REPS table. Ensure
that the amount entered is above zero.
5. Create a table named BOOK_STORES to include the columns listed in the following chart.
6. Add a constraint to make sure the Rep_ID value entered in the BOOK_STORES table is a valid value
contained in the STORE_REPS table. The Rep_ID columns of both tables were initially created as
different datatypes. Does this cause an error when adding the constraint? Make table modifications as
needed so that you can add the required constraint.
Store_ID NUMBER(8)
Name NUMBER(5)
Quarter CHAR(3)
Rep_ID NUMBER(5)
*If The IMAGE of screenshot is not readable.Below is the manually written query.
10. Issue the commands to disable and then enable the CHECK constraint on the Base_salary column.