Question 1. For each table, identify the primary key and the foreign key(s). If a table does not have a foreign key, write None.
Question 2. Do the tables exhibit entity integrity? Answer yes or no, and then explain your answer.
Question 3. Do the tables exhibit referential integrity? Answer yes or no, and then explain your answer. Write NA (Not Applicable) if the table does not have a foreign key.
Question 4. Describe the type(s) of relationship(s) between CUSTOMER and INVOICE.
Question 5. Describe the type(s) of relationship(s) between PRODUCT, LINE and INVOICE.
Question 6. Create the ERD to show the relationships among PRODUCT, LINE, and INVOICE.
Question 1:
Please find below the primary key and foreign key for the tables:
Table |
Primary key |
Foreign key |
CUSTOMER |
Cus_Code |
NA |
INVOICE |
Inv_Number |
Cus_Code from CUSTOMER(Cus_Code) |
VENDOR |
V_Code |
NA |
PRODUCT |
P_Code |
V_Code from VENDOR(V_Code) |
LINE |
(Inv_Number, Line_Number) |
1. Inv_Number from
INVOICE(Inv_Number) |
Question 2:
All the tables shared in the ERD exhibit entity integrity as:
1. All the tables must have a unique value for primary key identified in question 1.
2. The tables are not allowed to have null value in the primary key.
Question 3:
Please fine below the tables and corresponding referential integrity:
Table |
Has referential integrity |
Details |
CUSTOMER |
NA |
NA |
INVOICE |
Yes |
Each invoice will have a reference to a Customer which is identified by a Cus_Code. A Customer can have many INVOICE, but an INVOICE should be related to one CUSTOMER. |
VENDOR |
NA |
NA |
PRODUCT |
Yes |
Each prouct has a reference to Vendor in Vendor table as it is supplied by a VENDOR. |
LINE |
Yes |
LINE table stores the products
included in the invoice along with the quantity of poduct. It has
below references: |
Question 4.
CUSTOMER can have none or many INVOICES whereas an INVOICE must have exactly one CUSTOMER for it. Thus this is a One to Many relationship between CUSTOMER and INVOICE.
Question 5:
A PRODUCT is included in none or many LINE records. An INVOICE can have none or many LINE. Below are the relationships between the entities:
PRODUCT to LINE is a One to Many relationship.
LINE TO INVOICE is a Many to One relationship.
Question 6: ERD as below:
Question 1. For each table, identify the primary key and the foreign key(s). If a table...
Using the ch08_saleco database write a T-SQL query to display the customer code, invoice number invoice date, and invoice subtotal from invoice conditioned on the invoice subtotal is greater than $100 and from only customer codes 10011 and 10012. (hint: in) /* Database Systems, 8th Ed., Rob/Coronel */ /* Type of SQL : SQL Server */ CREATE TABLE CUSTOMER ( CUS_CODE int, CUS_LNAME varchar(15), CUS_FNAME varchar(15), CUS_INITIAL varchar(1), CUS_AREACODE varchar(3), CUS_PHONE varchar(8), CUS_BALANCE float(8) ); INSERT INTO CUSTOMER VALUES('10010','Ramas','Alfred','A','615','844-2573','0'); INSERT...
All the required files are attached to this question here in the form of images. Please refer the attached images and answer the questions. List the names and codes of vendors and the number of products each vendor has supplied, i.e. vendor AA has supplied xxx products, and vendor BB has supplied yyy products etc. Show the total value of invoices for each customer with the customer the Last Name, and a column heading showing ‘Total_invoice_value’ in the results. List...
CUSTOMER EMP INVOICE LINE P CODE V CODE CUS CODE EMP CODE NV NUMBER NV NUMBER, LINE NUMBER Create SQL queries for displaying the following results 5. List the customers who have ordered product bearing product code "23109-HB. Display first names, last names of customers, invoice numbers and product codes 6. Display Vendor details (V_CODE, V NAME) and product details (P CODE, P DESCRIPT) and product quantity on hand in excess of product min quantity (give alias of Quantity above...
Create SQL statements based on the given tables: Code to create the tables: CREATE DATABASE LAB4DB; USE LAB4DB; CREATE TABLE CUSTOMER ( CUS_CODE int primary key, CUS_LNAME varchar(15), CUS_FNAME varchar(15), CUS_INITIAL varchar(1), CUS_AREACODE varchar(3), CUS_PHONE varchar(8), CUS_BALANCE float(8) ); INSERT INTO CUSTOMER VALUES('10010','Ramas','Alfred','A','615','844-2573','0'); INSERT INTO CUSTOMER VALUES('10011','Dunne','Leona','K','713','894-1238','0'); INSERT INTO CUSTOMER VALUES('10012','Smith','Kathy','W','615','894-2285','345.86'); INSERT INTO CUSTOMER VALUES('10013','Olowski','Paul','F','615','894-2180','536.75'); INSERT INTO CUSTOMER VALUES('10014','Orlando','Myron','','615','222-1672','0'); INSERT INTO CUSTOMER VALUES('10015','O''Brian','Amy','B','713','442-3381','0'); INSERT INTO CUSTOMER VALUES('10016','Brown','James','G','615','297-1228','221.19'); INSERT INTO CUSTOMER VALUES('10017','Williams','George','','615','290-2556','768.93'); INSERT INTO CUSTOMER VALUES('10018','Farriss','Anne','G','713','382-7185','216.55'); INSERT INTO CUSTOMER VALUES('10019','Smith','Olette','K','615','297-3809','0'); /*...
Create a stored procedure named prc_inv_amounts to update the INV_SUBTOTAL, INV_TAX, and INV_TOTAL. The procedure takes the invoice number as a parameter. The INV_SUBTOTAL is the sum of the LINE_TOTAL amounts for the invoice, the INV_TAX is the product of the INV_SUBTOTAL and the tax rate (8 percent), and the INV_TOTAL is the sum of the INV_SUBTOTAL and the INV_TAX /* Database Systems, Coronel/Morris */ /* Type of SQL : SQL Server */ /* WARNING: */ /* WE HIGHLY RECOMEND...
We will use a simple database composed of the following tables: CUSTOMER, INVOICE, LINE, PRODUCT, and VENDOR. This database model is shown in Figure 1. The database model in Figure 1 reflects the following business rules: - A customer may generate many invoices. Each invoice is generated by one customer. - An invoice contains one or more invoice lines. Each invoice line is associated with one invoice. - Each invoice line references one product. A product may be found in...
* myCompany.SQL Introduction to SQL Script file for ORACLE DBMS This script file creates the following tables: VENDOR, PRODUCT, CUSTOMER, INVOICE, LINE EMPLOYEE and loads the default data rows */ set echo on; set serveroutput on; select systimestamp from dual; show user; ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY'; DROP TABLE LINE CASCADE CONSTRAINTS; DROP TABLE INVOICE CASCADE CONSTRAINTS; DROP TABLE CUSTOMER CASCADE CONSTRAINTS; DROP TABLE PRODUCT CASCADE CONSTRAINTS; DROP TABLE VENDOR CASCADE CONSTRAINTS; DROP TABLE EMPLOYEE CASCADE CONSTRAINTS; CREATE TABLE...
18,000 ACR7.1 (Perpetual Method) Jeter Co. uses a perpetual inventory system and both an accounts receivable and an accounts payable subsidiary ledger Balances related to both the general ledger and the subsidiary ledgers for Jeter are indicated in the working papers presented below. Also below are a series of transactions for Jeter Co. for the month of January, Credit sales terms are 2/10, n/30. The cost of all merchandise sold was 80% of the sales price. GENERAL LEDGER Account January...
oracle only database: DROP TABLE ORDERITEMS; DROP TABLE Orders; DROP TABLE BOOKAUTHOR; DROP TABLE BOOKS; DROP TABLE PROMOTION; DROP TABLE AUTHOR; DROP TABLE CUSTOMERS; DROP TABLE PUBLISHER; CREATE TABLE Customers ( Customer# NUMBER(4), LastName VARCHAR2(10) NOT NULL, FirstName VARCHAR2(10) NOT NULL, Email VARCHAR(40), Address VARCHAR2(20), City VARCHAR2(12), State VARCHAR2(2), Zip VARCHAR2(5), Referred NUMBER(4), Region CHAR(2), CONSTRAINT customers_customer#_pk PRIMARY KEY(customer#) ); INSERT INTO CUSTOMERS VALUES (1001, 'MORALES', 'BONITA', '[email protected]', 'P.O. BOX 651', 'EASTPOINT', 'FL', '32328', NULL, 'SE'); INSERT INTO CUSTOMERS VALUES...
Table 1 Table 2 Table 3 Table 4 Table 1 Profitability Efficiency 52-Week Leverage Information is relevant for the close of trade on Wednesday 02-Jan-2019 High Low ROE PM TATO EM 1. Google (end Q4 2018) 894.58 0.0866 1.1911 1214.16 0.155013 1.5028 Year end 2018 0.131142 0.078 1.1078 1.5177 Lowe's (end Q4 2018) 2. 54.08 35.73 0.166332 0.043 1.8734 2.0648 Year end 2018 0.201762 0.0505 1.9186 2.0824 3. Dick's Sporting Goods (end Q4 2018) 23.92 1.5795 4.4118 67.49 0.376993 0.0541...