Question: To Do: Open pgAdmin and create a new database called co-op. Copy and paste the the SQL Script in SQL Script for Co-op Database into

To Do:

Open pgAdmin and create a new database called "co-op."

Copy and paste the the SQL Script in SQL Script for Co-op Database into a new query tool and run it.

Create four additional tables:

Write an SQL script to create the following tables:

purchase --that contains a serial id for the purchase a date for the purchase. (you can make it timestamp and give it the default of current_timestamp), the id of the supplier as a foreign key and the id of the employee making the purchase as a foreign key.

purchasedetail--that will have a purchasedetailid as a primary key, purchaseid as a foreign key, item description as text, units as text, quantity and purchase price.

sale--which will have the saleid as primary key, employeeid and memberid as foreign keys, and saledate which can also be a timestamp with a defaulr of current_timestamp.

saledetail--which will have a saledetailid as primary key, saleid as a foreign key, inventoryid as a foreign key, quantity and discount. (Discount should be numeric. You can give it a default of 0 if you wish)

Things to watch for:

Make sure everything is spelled correctly. Field and table names in foreign keys have to match exactly. Also watch your commas. Every command ends with a comma except the last one. There should be a semicolon after the last parenthesis.

To Turn in:

Ideally, I would like to see two things: a SQL script for the four tables and a screen shot of the database tables in the pgAdmin object window, but if you can only do one--I want to see the the SQL Script.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!