Professional Documents
Culture Documents
Dit1206 DDM Assignment July 2021
Dit1206 DDM Assignment July 2021
Haas Consult Enterprise company has a number of sales offices in several regions.
Attributes of the Office include: OfficeID (Primary key), Manager, Location. Manager is
assigned to manage the office
Each office is assigned employees. Attributes of employees include: Employee_ID
(Primary Key), Employee_name, OfficeID. An employee must be assigned to only one
office.
The company lists property for sale. Attributes of property include PropertyID
(Primary key), Value, location, officeID.
Each unit of property must be listed with one office. An office can have a number of
properties listed and may have no properties listed.
Each unit of property can have one or more clients. Clients of the company are owners
of the properties. Attributes of the client are clientID, client_name, Address
Value
Manager Emp_Name
Location
Location F.K OfficeID
F.K OfficeID
CLIENT
P.K ClientID
Client_Name
Address
QUESTION 2: DATA DEFINITION LANGUAGE (DDL)
Tables:
1. Product: create table Product (ProductID varchar (7), Description varchar (60), Price int
(15) NOT NULL, Manufacturer varchar (50), Qty_on_Hand int (15) NOT NULL), PRIMARY
KEY(ProductID));
2. Office: create table Office (OfficeID varchar (7), City varchar (20) NOT NULL, Region
varchar (20) NOT NULL, Manager varchar (7), Target decimal (10,2) check (Target >=
5000), Sales decimal (10,2) check (Sales >= 5000), PRIMARY KEY (OfficeID), UNIQUE
KEY(Manager));
3. SalesRep: create table SalesRep (SalRepID varchar (7), SalRepName varchar (60),
OfficeID varchar (7), Hiredate date CHECK (Hiredate >= 2000-01-1), Manager varchar
(7), Quota varchar (15) NOT NULL, Sales decimal (10,2) check (Sales >= 500), Target
decimal (10,2) check (Target >= 500), PRIMARY KEY (SalRepID), FOREIGN KEY (OfficeID)
REFERENCES Office (OfficeID));
Then: Alter table SalesRep add foreign key (Manager) REFERENCES Office(Manager);
4. Customer: create table Customer (CustomerID varchar (7), CustomerName varchar (60),
Company varchar (20), Address varchar (20) NULL, SalRepID varchar (7), CreditLimit
decimal (10,2) CHECK (CreditLimit >= 500), PRIMARY KEY (CustomerID), FOREIGN KEY
(SalRepID) REFERENCES SalesRep (SalRepID));
5. Order: create table 0rder (0rderID varchar (7), CustomerID varchar (7), ProductID
varchar (7), Qty int (15) NOT NULL, Amount int (15) NOT NULL, SalRepID varchar
(7),Date date CHECK (Date >= 2000-01-1), PRIMARY KEY (0rderID), FOREIGN
KEY(CustomerID) REFERENCES Customer (CustomerID));
Then - alter table 0rder add FOREIGN KEY (ProductID) REFERENCES Product (ProductID);
alter table 0rder add FOREIGN KEY (SalRepID) REFERENCES SalesRep (SalRepID);
iv.