Answered step by step
Verified Expert Solution
Question
1 Approved Answer
[ mailAddress ) PL OYEE ( EmployeeID , LastName, FirstName, Phone, EmailAdeirstName, Ad - NDOR ( VendorlD , CompanyName, ContactLastName, ContactFirstName, M ( lemiD ,
mailAddress
PL OYEE EmployeeID LastName, FirstName, Phone, EmailAdeirstName, Ad
NDOR VendorlD CompanyName, ContactLastName, ContactFirstName, M lemiD State, ZIP, Phone, Fax, EmailAddress
I SaleII CustomerID, EmployeeID, SaleD Item Cost, ItemPrice, VendorID
F ITEM SaleID SaleItemID, ItemID, ItemPrice, SubTotal, Tax, Total
referential integrity constraints are:
worlD in TTEM must exist in VendorID in VENDOR
avmerID in SALE must exist in CustomerID in CUSTOMER
uptoyecID in SALE must exist in EmployeeID in EMPLOYEE
ateli in SALE ITEM must exist in SaleID in SALE
ID in SALE ITEM must exist in ItemID in ITEM
A ssume that CustomerID of CUSTOMER, EmployeeID of EMPLOYEE, VendorID of VEN. DORE, IremID of ITEM, and SaleID of SALE are all surrogate keys with values as follows:
tableCustomerIDStart at Increment by FimployeelDStart at Increment by VendorIDStart at Increment by ltemIDStart at Increment by SalelDStart at Increment by
SaleItemID of SALEITEM is not a true surrogate key, but rather a counter that starts at and increments by for each SaleID in SALE. This number will require special handling in the database, needing to be either manually inserted or to have specific program logic written to insert the correct number. In this text we will simply insert the number manually.
A vendor may be an individual or a company. If the vendor is an individual, the CompanyName field is left blank, while the ContactLastName and ContactFirstName fields must have data values. If the vendor is a company, the company name is recorded in the CompanyName field, and the name of the primary contact at the company is recorded in the ContactLastName and ContactFirstName fields.
Sample data are shown in Figure Figure Figure Figure Figure and Figure These tables, referential integrity constraints, and data are used as the basis for the SQL statements you will create in the exercises that follow. If possible, run these state ments in an actual DBMS as appropriate, to obtain your results. Name your database QACS
Use data types consistent with the DBMS you are using. If you are not using an actua DBMS consistently represent data types using either the MySQL Microsoft SQL Serve or Oracle Database data types shown in Figure For each SQL statement you write show the results based on your data.
Write SQL statements and answer questions for this database as follows:
A Write SQL CREATE TABLE statements for each of these tables. Omit foreign keys.
B Write foreign key constraints for the relationships in each of these tables. Make you own assumptions regarding cascading deletions and justify those assumptions. Hin You can combine the SQL for your answers to parts A and B
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started