Question: Construct a SQL Data Definition Language (DDL) for the following statement: a) Define the ORDERS relation which has the following constraints. Data Type Constraints

Construct a SQL Data Definition Language (DDL) for the following statement: a) Define the ORDERS relation

Construct a SQL Data Definition Language (DDL) for the following statement: a) Define the ORDERS relation which has the following constraints. Data Type Constraints Attribute orderNo Integer of length 7 Primary Key ordDate custNo prodNo quantity Date Various characters of length 5 Foreign Key where the reference relation is Various characters of length 6 Integer CUSTOMER(custNo) Foreign Key where the reference PRODUCT(pCode) relation is b) Modify the ORDERS relation such that the attribute order No holds the same data type as prodNo in PRODUCT relation. c) Add a new attribute named totalPrice in the ORDERS relation that reflects the total sum of money to be paid for the order. d) Add a constraint to the totalPrice attribute in the ORDERS relation where the default value is set to NOT NULL. e) Create a new relation named NEWORDERS that has the same structure as ORDERS. f) Delete the ORDERS relation from your database. g) Recover the deleted ORDERS relation to your database and rename the relation to OLDORDERS.

Step by Step Solution

3.40 Rating (156 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Please upload or attach ... View full answer

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!