2
 DBAS 55892 Assignment Sheridan Institute DBAS 55892 Assignment 2 Due Date: the day of the final examination Part I. 1. You are a bout to cr eate a ta ble and re member that one o f the col umns ha s to incl ude a NOT  NULL constraint. Modify the following SQL command so that the column named colC cannot contain a NULL value, and then create a table. CREATE TABLE homework (c ol A NUMBER, colB NUMBER(8,0 ), colC DATE DEFAULT SYSDATE, co lD VARCHAR2(2 )); 2. Change the HOMEWOR K table s o colA a nd colB t ogether ar e the pr imary key for t he table . 3. Add a col umn to t he HOMEWOR K table with the na me colE . This col umn shoul d only be allowed to contain numeric values between 3 and 8. Name the constraint homework_colE_ck. 4. Change t he HOMEWOR K table s o that t he colB can only cont ain value s that ar e store d in the Order ID column of the ORDERS table in your database schema. Make certain that after you make the change, colB is still part of the composite key created in Step 2. 5. Issue a se lect statement that would all ow you to view t he condition s for all t he CHECK o n the HOMEWORK table. 6. Add anot her colum n to the H OMEWORK table. This column s hould be n amed colF and be able to store dates. Although the column is no part of the primary key, it should not be allowed to contain any duplicate or NULL values. 7. Dis able t he const rai nt name d homew ork_ colE _ck . 8. You have d ecided t hat the pr imary k ey for t he HOMEWOR K table s hould onl y consis t of column cola. Make the changes needed to make cola the only column used for the table’s  primary key. 9. Enab le the co nst rai nt named homewo rk_ colE _ck . 10. Change the constraint on colB that references the ORDERS table so that if an order is deleted from the ORDERS table, any entries in the HOMEWORK table related to that order will automatically be deleted also. Part II 1. Writ e the command to c reate a p ublic sy nonym nam ed PUB LIC_ STUDENT for the STUDENT table in your database schema. Page 1 of 2

DBAS 55892 Assignment 2 Winter 2012

Embed Size (px)

Citation preview

5/14/2018 DBAS 55892 Assignment 2 Winter 2012 - slidepdf.com

http://slidepdf.com/reader/full/dbas-55892-assignment-2-winter-2012 1/3

 

DBAS 55892 Assignment Sheridan Institute

DBAS 55892 Assignment 2Due Date: the day of the final examination

Part I.

1. You are about to create a table and remember that one of the columns has to include a NOT

 NULL constraint. Modify the following SQL command so that the column named colC cannotcontain a NULL value, and then create a table.

CREATE TABLE homework 

(colA NUMBER,colB NUMBER(8,0),

colC DATE DEFAULT SYSDATE,

colD VARCHAR2(2));

2. Change the HOMEWORK table so colA and colB together are the primary key for the table.

3. Add a column to the HOMEWORK table with the name colE. This column should only beallowed to contain numeric values between 3 and 8. Name the constraint homework_colE_ck.

4. Change the HOMEWORK table so that the colB can only contain values that are stored in theOrder ID column of the ORDERS table in your database schema. Make certain that after you

make the change, colB is still part of the composite key created in Step 2.

5. Issue a select statement that would allow you to view the conditions for all the CHECK on the

HOMEWORK table.

6. Add another column to the HOMEWORK table. This column should be named colF and be

able to store dates. Although the column is no part of the primary key, it should not be allowedto contain any duplicate or NULL values.

7. Disable the constraint named homework_colE_ck.

8. You have decided that the primary key for the HOMEWORK table should only consist of column cola. Make the changes needed to make cola the only column used for the table’s

 primary key.

9. Enable the constraint named homework_colE_ck.

10. Change the constraint on colB that references the ORDERS table so that if an order is deletedfrom the ORDERS table, any entries in the HOMEWORK table related to that order willautomatically be deleted also.

Part II

1. Write the command to create a public synonym named PUBLIC_STUDENT for the

STUDENT table in your database schema.

Page 1 of 2

5/14/2018 DBAS 55892 Assignment 2 Winter 2012 - slidepdf.com

http://slidepdf.com/reader/full/dbas-55892-assignment-2-winter-2012 2/3

 

DBAS 55892 Assignment Sheridan Institute

2. Create a private synonym PRIVATE_FACULTY for the FACULTY table in your databaseschema.

3. Write the command to select F_ID, F_LAST, and F_FIRST fields from all of the records inyour FACULTY table using your private synonym.

4. Create a sequence that will generate integers starting with the value 9. Each value should bethree less than the previous value generated. The lowest possible value the sequence should beallowed to generate is -1, and it should not be allowed to cycle. Name the sequence

MY_FIRST_SEQUENCE.

Page 2 of 2

5/14/2018 DBAS 55892 Assignment 2 Winter 2012 - slidepdf.com

http://slidepdf.com/reader/full/dbas-55892-assignment-2-winter-2012 3/3