Question

The next question uses the following relations, which model an inventory management system

product(product_id, name, price)

inventory(product_id, count)

shipments(shipment_id, product_id, count, delivery_date)

8. (10 points) Write the table creation queries for the above relations, along with the indicated primary keys and the obvious foreign key relationships, and a check constraint restricting the count and price columns to non-negative values.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

For the product table, the product id is a primary key, name is a string and price a positive number hence
CREATE TABLE product {
product_id int,
name varchar(255),
price int CHECK (price >= 0),
PRIMARY KEY (product_id)
}

Inventory also has product_id as its primary key but its also a foreign key. Also, it needs check on count.
CREATE TABLE inventory{
product_id int,
count int CHECK (count >= 0),
PRIMARY KEY (product_id),
FOREIGN KEY (product_id) REFERENCES product(product_id)
}

shipments has shipment_id as primary key, product_id as foreign key, count must be non-negtive.
CREATE TABLE shipments{
shipment_id int,
product_id int,
count int CHECK (count >= 0),
delivery_date DATE,
PRIMARY KEY (shipment_id),
FOREIGN KEY (product_id) REFERENCES product(product_id)
}

Comment in case of any doubts.

Add a comment
Know the answer?
Add Answer to:
The next question uses the following relations, which model an inventory management system product(product_id, name, price)...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Tables names are not given, According to the 1st Question we have to name them from...

    Tables names are not given, According to the 1st Question we have to name them from the given Key names, Like this; The first several questions use the following tables, which model a ticketing system (the venue table is mentioned but not shown). holderId eventId holderId name eventId name venue date 10 20 30 John Ella Miles Lilo ComicCon Jazzfest MakerFaire 300 100 200 2019-07-18 2019-04-06 2019-05-17 10 ticket number 10000 10001 200 210 101 100 20 1. The above...

  • Topic: Inventory Manangement Part A. Database Creation Your database should have a minimum of 4 tables...

    Topic: Inventory Manangement Part A. Database Creation Your database should have a minimum of 4 tables and include both one-to-many and many-to-many relationships. Be sure to include some numeric and/or date fields. Define all appropriate constraints, using the proper naming conventions (see Structure Notes below). Populate your database with at least 30 records in the main table(s), and whatever is needed in related tables. Submit the following: • a short description of the purpose of the database and what the...

  • using SQL Assume the relations shown below (underlined attributes are primary and foreign keys): merchants(mid, name,...

    using SQL Assume the relations shown below (underlined attributes are primary and foreign keys): merchants(mid, name, city, state) products(pid, name, category, description) sell(mid, pid, price, quantity_available) orders(oid, shipping_method, shipping_cost) contain(oid,pid) customers(cid, fullname, city, state) place(cid, oid, order_date)   For each of the following questions write a SQL query: List names and sellers of products that are no longer available (quantity=0) List names and descriptions of products that are not sold. How many customers bought SATA drives but not any routers between 2009...

  • Consider the following data about some musicians irth_year country instr instrument_category genre name USA USA USA...

    Consider the following data about some musicians irth_year country instr instrument_category genre name USA USA USA Scotland voice Mexico USA Australia guitar, voice string, wind Sth Korea voice Pat Metheny Taylor Swift Yo-Yo Ma Susan Boyle Antonio Sanchez 1971 Wynton Marsalis 1961 Keith Urban Kwon Ji-yo 1954 1989 1955 1961 guitar guitar, voice string, wind cello string azz pop, country classical classical string wind percussion brass drums azz trumpet azz 1967 ng1989 countrv wind pop Design a database, in third...

  • Exercise 3 [12.5 marks] Given the Restaurant management system database that contains the following tables (primary...

    Exercise 3 [12.5 marks] Given the Restaurant management system database that contains the following tables (primary keys are underlined and foreign keys are preceded with #): Customer (customerID,customerFirstName,customerLastName,customerAddress) Oreder (orderID,orderDate, #customerID,#menuItemID,#staffID) MenuItem(menuItemID, menuItemName,ingredients,type,availability) Staff(staffID, staffName, staffPhoneNumber, staffRole ) OrderPayment(paymentID,paymentAmount,#orderID,#staffID) 1) Without using DISTINCT, write the SQL query equivalent to the following one:[1.5 marks] SELECT DISTINCT menuItemName FROM MenuItem WHERE type = ‘Vegetarian’ OR availability= ‘Yes’; 2) Express the following queries in SQL: a) Find the number of orders placed by...

  • I NEED TO WRITE THE FOLLOWING QUERIES IN MYSQL (13)Next, grant to a user admin the read privileges on the complete descr...

    I NEED TO WRITE THE FOLLOWING QUERIES IN MYSQL (13)Next, grant to a user admin the read privileges on the complete descriptions of the customers who submitted no orders. For example, these are the customers who registered themselves and submitted no orders so far. The granted privilege cannot be propagated to the other users. 0.3 (14)Next, grant to a user admin the read privileges on information about the total number of orders submitted by each customer. Note, that some customers...

  • Create a procedure to update the sales history table following the requirements below. A table creation...

    Create a procedure to update the sales history table following the requirements below. A table creation script is provided below. a) Call the procedure: UPDATE_SALES_HISTORY (The procedure name is important for our scripts to test and grade your code; please do not rename it (otherwise our scripts will not run and your score will be 0). b) The procedure takes 2 parameters: (4-digit-year, 2-digit-month). Both parameters will be numeric, e.g., (2019, 11) will denote 2019 (year) and November (month). The...

  • Provide the syntax answers for the following script, doesn't matter what table or columns. CREATE TABLE...

    Provide the syntax answers for the following script, doesn't matter what table or columns. CREATE TABLE customer (c_id NUMBER(5), c_last VARCHAR2(30), c_first VARCHAR2(30), c_mi CHAR(1), c_birthdate DATE, c_address VARCHAR2(30), c_city VARCHAR2(30), c_state CHAR(2), c_zip VARCHAR2(10), c_dphone VARCHAR2(10), c_ephone VARCHAR2(10), c_userid VARCHAR2(50), c_password VARCHAR2(15), CONSTRAINT customer_c_id_pk PRIMARY KEY (c_id)); CREATE TABLE order_source (os_id NUMBER(3), os_desc VARCHAR2(30), CONSTRAINT order_source_os_id_pk PRIMARY KEY(os_id)); CREATE TABLE orders (o_id NUMBER(8), o_date DATE, o_methpmt VARCHAR2(10), c_id NUMBER(5), os_id NUMBER(3), CONSTRAINT orders_o_id_pk PRIMARY KEY (o_id), CONSTRAINT orders_c_id_fk FOREIGN...

  • Read the Article posted below, then answer the following questions: Mergers & acquisitions are a major...

    Read the Article posted below, then answer the following questions: Mergers & acquisitions are a major form of corporate diversification strategy, identify and discuss the top three reasons why most (50-60%) of acquisitions fail to create shareholder value. What are the five major components of “CEMEX Way” and why has this approach been so successful in post-acquisition integration? In your opinion, what can other companies learn from the “CEMEX Way” as a benchmark for acquisition management? Article: CEMEX: Globalization "The...

  • What an Executive Summary Is An executive summary is a specific type of document that does...

    What an Executive Summary Is An executive summary is a specific type of document that does two things: it summarizes a research article, and it offers recommendations as to how information from the article can be used. Some long reports can contain an executive summary section, as indicated in the Pearson handbook. Write a 2 pahe Executive Summary In business contexts, an executive summary is always written for a specific purpose: to explain the information in the article to a...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT