Question

In: Computer Science

For the given database schema. Answer the following questions. Company Database customer(cust_id, name, address) product(product_id, product_name,...

For the given database schema. Answer the following questions.

Company Database customer(cust_id, name, address)

product(product_id, product_name, price, quantity)

transaction(trans_id, cust_id, time_date)

product_trans(product_id, trans_id)

Identify the primary keys and foreign keys for the relations and specify at least two different types of integrity constraints that would be applicable for different relations given.

Solutions

Expert Solution

given the following relations

1) customer(cust_id, name, address)

          - > primary key is cust_id

2) product(product_id, product_name, price, quantity)

          - > primary key is product_id

3) transaction(trans_id, cust_id, time_date)

           - > primary key is trans_id

        -> foreign key is cust_id referencing cust_id of relation customer

4) product_trans(product_id, trans_id)

           -> primary key is trans_id +product_id , it s a composit key

           -> both are foreign keys

                        foreign key 1 is, trans_id referencing trans_id of relation transaction

                        foreign key 2 is, product_id referencing product_id of relation product

------------------------------------------------------------------------

different integrity constraints applcable on the above relation are

1. Domain constraints ( definition of valid set of value for an attribute eg:- int , char , .... datatype )

2. Entity integrity constraints ( primary key value can't be null. )

3. Referential Integrity Constraints ( foreign keys can be used )

4.Key constraints( A primary key should contain unique value)

                    


Related Solutions

Consider the following relational schema: Salerep(sales_rep_ID, name, address, commission, rate) Customer(customer_number, name, address, balance, credit_limit, sales_rep_ID)...
Consider the following relational schema: Salerep(sales_rep_ID, name, address, commission, rate) Customer(customer_number, name, address, balance, credit_limit, sales_rep_ID) Part(part_number, part_description, on_hand, class, warehouse, price) Orders(order_number, order_date, customer_number) Orderlilne(order_number, part_number, number_order) Write SQL statements for the following queries: a) Produce a list showing part_number, part_description, on_hand, and price sorted by part_description. b) List customer’s name followed by order_number, part_description, and number_order. c) List names of customers who have ordered the most expensive item(Hint: Use a nested SQL query to determine thehighest price.) d)...
[Q.4] Answer the following questions You are invited as a database architect to develop database schema...
[Q.4] Answer the following questions You are invited as a database architect to develop database schema for maintaining patient information for the NYU medical group (make necessary assumptions for the data requirements if needed). Each physician in the Lehman medical group is uniquely identified by physicianID o Each physician must have first name, and last name, and phone number Each patient is identified by patientID o Each patient must have first name, and last name, phone number, and insurance card...
Problem: Read the following tables and answer the following questions: Customers Customer ID Name Address Phone...
Problem: Read the following tables and answer the following questions: Customers Customer ID Name Address Phone Email 9087 John Doe 204 University Ave. 987-098-9087 Doe@ibm.net 2098 Bill Lawrence 123 Jones St 717-387-3387 Business 2398 Laura Smith 0900 West Blvd. 901-234-4567 Information Transactions Customer ID Account Number Date of Last Transaction 9087 375 01/31/98 2098 123 03/09/97 2398 375 09/21/97 2098 375 12/31/97 2398 123 02/01/98 Accounts Account Number Balance Account Type 375 234.45 Checking 123 056.90 Savings 1. Who owns...
The schema for the Academics database is as follows. Understanding this schema is necessary to answer...
The schema for the Academics database is as follows. Understanding this schema is necessary to answer the questions in Part B. DEPARTMENT(deptnum, descrip, instname, deptname, state, postcode) ACADEMIC(acnum, deptnum*, famname, givename, initials, title) PAPER(panum, title) AUTHOR(panum*, acnum*) FIELD(fieldnum, id, title) INTEREST(fieldnum*, acnum*, descrip) The semantics of most attributes are self-explanatory. For each relation, the primary key is underlined and any foreign keys are denoted by an asterisk (*). Some additional information for relations is given below: DEPARTMENT: Each academic department...
Given the following relational schema, write queries in SQL to answer the English questions. There is...
Given the following relational schema, write queries in SQL to answer the English questions. There is a shipment database on the MySQL server. You can also use the DDL for MySQL. You must only submit the SQL for your answers but you can include the query output as well to help the TA with marking. Customer(cid: integer, cname: string, address: string, city: string, state: string) Product(pid: integer, pname: string, price: currency, inventory: integer) Shipment(sid: integer, cid: integer, shipdate: Date/Time) ShippedProduct(sid:...
Given the following relational schema, write queries in SQL to answer the English questions. There is...
Given the following relational schema, write queries in SQL to answer the English questions. There is a shipment database on the MySQL server. You can also use the DDL for MySQL. You must only submit the SQL for your answers but you can include the query output as well to help the TA with marking. Customer(cid: integer, cname: string, address: string, city: string, state: string) Product(pid: integer, pname: string, price: currency, inventory: integer) Shipment(sid: integer, cid: integer, shipdate: Date/Time) ShippedProduct(sid:...
Consider the following database schema:                Product(maker, model, type)                PC(model, speed
Consider the following database schema:                Product(maker, model, type)                PC(model, speed, ram, hd, rd, price)                Laptop(model, speed, ram, hd, screen, price)                Printer(model, color, type, price) Give SQL statement for each of the following: (Grouping and Aggregation) Write the following queries in SQL: Find the average speed of laptops costing over $2000. Find the average price of PC’s and laptops made by manufacturer “D”. Find, for each manufacturer, the average screen size of its laptops. Find the manufacturers...
Consider the following database schema:                Product(maker, model, type)                PC(model, speed
Consider the following database schema:                Product(maker, model, type)                PC(model, speed, ram, hd, rd, price)                Laptop(model, speed, ram, hd, screen, price)                Printer(model, color, type, price) Give SQL statement for each of the following: (Subqueries, Join operations) Write the following queries in SQL: Find the makers of PC’s with a speed of at least 1200. Find the printers with the highest price. Find the laptops whose speed is lower than that of any PC. Find the model number...
SQL query exercises: Consider the following database schema:                Product(maker, model, type)              &
SQL query exercises: Consider the following database schema:                Product(maker, model, type)                PC(model, speed, ram, hd, rd, price)                Laptop(model, speed, ram, hd, screen, price)                Printer(model, color, type, price) Consider the Drivers-Cars-Reserves DB for a small rental car company:                Drivers(id, name, rating, age)                Cars(vin, maker, model, year, color)                Reserves(did, vin, date) Give SQL statement each of the following operations: Find the colors of cars reserved by Smith. Find all id’s of drivers who have a...
All questions in this assignment refer to the “om” database (or Schema) that you will find...
All questions in this assignment refer to the “om” database (or Schema) that you will find in your MySQL Workbench program if you have run the sample database install script. Please save all of your answers in one script (.sql) or type all your answers into Notepad++ and submit them as a single .sql file. You are encouraged to test your SQL statements in Workbench, and please use the ‘tidy’ tool to properly format your SQL before you save it...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT