0% found this document useful (0 votes)
19 views2 pages

Y23 Week23

Uploaded by

msci.2303
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views2 pages

Y23 Week23

Uploaded by

msci.2303
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Week2 & Week3

Part A (Session3 )
1. Identify two related entities (with their attributes)
and the relationship between these entities.
2. Create the tables
3. Insert some data into the tables
4. Practice the Alter Table constructs
5. Drop the tables

Part B (Session 4 & 5)

6. Create the table COMP with attributes Company_Name, Card_Number,


Starting_Value, Value_Left and Pin_Number. Choose the most
appropriate data types.
7. Now insert the same tuple in the table again. Does it allow you to do so?
Why or why not?
8. Create the same table again but now make some fields of the table
having mandatory values.
9. Add at least 4 tuples in the table. In at least one tuple, for the field that
you have specified as mandatory, do not put any value. Does the tuple
get inserted? Note the error message (if one is there).
10.Alter the table by dropping a column. Does it allow you to do so?
11.Can you always change a column from null to not null? What about not
null to null? How did you do this?
12.Add an unnamed primary key constraint on Card_Number and a unique
constraint on Pin_Number. Did oracle allow you to do this even after
data has been added? Justify why/why not.
13.Decrease the width of a column (say CardNumber) that has values in it.
Does it allow you?
14.Decrease the width of a table (remove a column) that has values. Does it
allow you?
15.Establish a default value for the Value_left attribute.
16.Insert a tuple with a null value for Pin_Number. Does it allow you to
enter a null value in this field?
17.Drop a table itself. When will it not allow you?
18.Truncate a table. What is the difference between Drop and Truncate?
19. Create another table called Person_info with attributes
(PersName,BirthDate,Card_Number,Date_Created). Add a few tuples into this table.
20. Which fields require a foreign key constraint to be added? Add a named (table level
constraint) foreign key constraint to the table? Did it allow you? Why or why not?
21. What did you do to be able to add the constraint?
1. Can you define a FK column with a data type different from the data type to which it references?
What error (if any) does it give you?

2. Add a FK constraint to a table with values that do not conform. What happens? Note the message
returned by Oracle

3. Try creating a FK on a table that references a non primary key attribute. Does oracle allow this?
4. Insert more data into the table that
a) conforms to the FK b)does not conform to the FK
Note the different messages that Oracle give you?

5. Can you drop data from a table to which a FK references? Why?


6. Ensure that you can drop data from the referenced table.

You might also like