Question

In: Computer Science

Marcia wants to keep track of each of her customers and their orders. Ultimately, she wants...

Marcia wants to keep track of each of her customers and their orders. Ultimately, she wants to notify them that their clothes are ready via email. Suppose that you have designed a database for Marcia’s Dry Cleaning that has the following tables:

CUSTOMER (CustomerID, FirstName, LastName, Phone, EmailAddress)

INVOICE (InvoiceNumber, CustomerID, DateIn, DateOut, Subtotal, Tax, TotalAmount)

INVOICE_ITEM (InvoiceNumber, ItemNumber, ServiceID, Quantity, UnitPrice, ExtendedPrice)

SERVICE (ServiceID, ServiceDescription, UnitPrice)

The referential integrity constraints are:

CustomerID in INVOICE must exist in CustomerID in CUSTOMER

InvoiceNumber in INVOICE_ITEM must exist in InvoiceNumber in INVOICE

ServiceID in INVOICE_ITEM must exist in ServiceID in SERVICE

Assume that CustomerID of CUSTOMER, EmployeeID of EMPLOYEE, ItemID of ITEM, SaleID of SALE, and SaleItemID of SALE_ITEM are all surrogate keys with values as follows: CustomerID Start at 100 Increment by 1

InvoiceNumber Start at 2018001 Increment by 1

D. Suppose that MArcia decides to allow multiple customers per order (e.g. for customers' spouses). Modify the design of these tables to accommodate this change.

E. Code SQL statements necessary to redesign the database, as described in your answer to question D.

F.Suppose that Marcia considers changing the primary key of CUSTOMER to (FirstName, LastName). Write correlated subqueries to display any data that indicate that this change is not justifiable.

Solutions

Expert Solution

D.

We will assume that the name has been changed from ORDER to CUST_ORDER as described above. If this is not done, the following steps will be the same - only the table name will be different. We have to modify the relationship between CUSTOMER and CUST_ORDER.

(1) Create intersection table. There may be foreign key constraints when creating a table or as a separate step.

(2) Copy the values ​​of the primary keys from the tables for rows that have an existing foreign match between the tables.

(3) Release the original foreign key. Constraints and foreign key columns for the parent child table.

If we will:

(1) Create ORDER_CUSTOMER_INT. Since we typically create foreign key constraints when creating a table, we will resolve foreign key constraints between ORDER_CUSTOMER_INT and CUSTOMER and between ORDER_CUSTOMER_INT and CUST_ORDER .

(2) Copy the values ​​of the primary keys from CUST_ORDER to CUSTOMER for rows that have an existing foreign key match from CUST_ORDER to CUSTOMER in ORDER_CUSTOMER_INT.

(3) Drop the original foreign key constraint and foreign key column for CUST_ORDER.

E.

(1) Create an intersection table. There may be significant foreign constraints when creating a table or as a separate step. In the case of defamation,

CREATE TABLE ORDER_CUSTOMER_INT(

InvoiceNumber Int NOT NULL,

CustomerID Int NOT NULL,

CONSTRAINT CustomerOrderIntPK

PRIMARY KEY (InvoiceNumber, CustomerID),

CONSTRAINT COInt_CustOrder_FK FOREIGN KEY(InvoiceNumber)

REFERENCES CUST_ORDER(InvoiceNumber)

ON UPDATE CASCADE

ON DELETE CASCADE,

CONSTRAINT COInt_Customer_FK FOREIGN KEY(CustomerID)

REFERENCES CUSTOMER(CustomerID)

ON UPDATE NO ACTION

ON DELETE NO ACTION

);

2. Copy the values ​​of the primary keys from the rows of the parent child table for rows that have an existing foreign key match from CUST_ORDER to CUSTOMER and the foreign key is not null.

INSERT INTO ORDER_CUSTOMER_INT(InvoiceNumber, CustomerID)

SELECT InvoiceNumber, CustomerID

FROM CUST_ORDER

WHERE CustomerID IS NOT NULL

3.

Skip the foreign key column for the original foreign key constraint and CUST_ORDER

LTER TABLE CUST_ORDER

DROP CONSTRAINT CustOrderCustomerFK;

ALTER TABLE CUST_ORDER

DROP COLUMN Custome

F.

Customer (Customer, FirstName, LastName, Phone, Email) If (FirstName, LastName) is going to be a primary key, the following functional dependencies must exist: (FirstName, LastName) and Phone, (FirstName, LastName) and Email

Who can be associated with this type: (FirstName, LastName) and (Phone, Email)

SELECT C1.CustomerID, C1.FirstName, C1.LastName

FROM CUSTOMER AS C1

WHERE C1.FirstName IN

(SELECT C2.FirstName

FROM CUSTOMER AS C2

WHERE C1.FirstName = C2.FirstName

AND C1.LastName = C2.LastName

AND C1.CustomerID <> C2.CustomerID);


Related Solutions

Ava wants to use a database to keep track of the data recordsfor her insurance...
Ava wants to use a database to keep track of the data records for her insurance company and to enforce the following business policies/requirements: USE MS ACCESS TO CREATE A DATABASE & RELATIONASHIP-Every customer must be uniquely identified.-A customer can have many insurance policies.-Every insurance policy must be uniquely identified.-An insurance policy must belong to a valid customer.-Every customer must be served by a valid insurance agent (employee).-An insurance agent (employees) serves many customers.-Every insurance agent (employee) must be uniquely...
González Industries requires its sales personnel to keep track of their weekly contacts with customers. A...
González Industries requires its sales personnel to keep track of their weekly contacts with customers. A sample of 16 reports showed a mean of 32.4 customer contacts per week for the sales personnel, and a sample standard deviation of 5.7 contacts. Assuming customer contacts is a normally distributed variable, generate a 95% confidence interval estimate of the true mean number of customer contacts per week at González Industries. Begin by stating whether this estimation problem should use the student t...
the college wants to keep track of the semester schedules across years. i.e. Departments, their Courses...
the college wants to keep track of the semester schedules across years. i.e. Departments, their Courses as they exist in the College catalog, and the course section offerings across the years and their semesters. From a catalogue perspective: A department has a unique name (Finance, Management and Marketing, Math, ABC-Law, etc.) and offers multiple courses. A course has a unique name, which is a hyphenated prefix-Number like (BUAN-310, CIS-205, FIN315, MATH-153, etc.), a long name like “principles of Data management”,...
As you complete each of the following steps, keep track of what occurs at each point;...
As you complete each of the following steps, keep track of what occurs at each point; including what you type, the output given, and any errors experienced. Submit this information in a log to your instructor for this week’s assignment. Your log can use the sample format provided, or you can create your own. 1. Run the following script: a. #!/bin/bash b. count=1 c. echo "start of the program" d. while [ $count -le 10 ] e. do 1) echo...
Task 2 introduction to software engineering A nursery wants to keep track of all its products,...
Task 2 introduction to software engineering A nursery wants to keep track of all its products, including plants, fountains, garden hardware (wheelbarrow, shovels etc) and also soil and sand which they sell. They buy all stock from the wholesalers. The management wants to know which staff members have been selling what, and from which wholesaler the products were purchased. There are also times when a customer returns a product for a refund, and such information should be available in the...
A gas station wants a program to keep track of sales. Your gas station sells diesel...
A gas station wants a program to keep track of sales. Your gas station sells diesel for 107.9 cents per litre and regular gas for 112.9 cents per litre. Have the user enter the type of fuel (1 = Regular gas, 2 = Diesel) and number of litres sold. Print out a total for each sale (remember fuel prices already include the GST). Once you enter a 0 for the type of fuel your program should stop and print out...
An amateur meteorologist wants to keep track of weather conditions during the past year's three -month...
An amateur meteorologist wants to keep track of weather conditions during the past year's three -month summer season and has designated each day as either rainy ('R'), cloudy ('C'), or sunny ('S'). Write a modu lar program that stores this information in a 3 x 30 array of characters, where the row indicates the month (0 = June, 1 = July, 2 = August) and the column indicates the day of the month. Note that data is not being collected...
Establishing a method for collecting rent each month will make it easier to keep track of...
Establishing a method for collecting rent each month will make it easier to keep track of the rent collection process. Choose the number of houses and rent per house by your choice. Develop a python program to maintain the rent collection process. Update the database with the details of every month like the name of the tenant, house number, month of the rent, rent amount, EB bill amount, maintenance charge, etc., Print the details of rent collection for all houses...
Tony Gaddis C++ Monkey Business A local zoo wants to keep track of how many pounds...
Tony Gaddis C++ Monkey Business A local zoo wants to keep track of how many pounds of food each of its three monkeys eats each day during a typical week. Write a program that stores this information in a two-dimensional 3 × 7 array, where each row represents a different monkey and each column represents a different day of the week. The monkeys are represented by integers 1, 2, and 3; the weekdays are "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday",...
Natalie is struggling to keep up with the recording of her accounting transactions. She is spending...
Natalie is struggling to keep up with the recording of her accounting transactions. She is spending a lot of time marketing and selling mixers and giving her cookie classes. Her friend John is an accounting student who runs his own accounting service. He has asked Natalie if she would like to have him do her accounting. John and Natalie meet and discuss her business. John suggests that he do the following for Natalie. 1.   Hold onto cash until there is...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT