You are on page 1of 2

A-Create the following tables with constraints.

Parent Table : PT Child Table : CH


Fields Fields
Id >>> number , primary key Id >>> number, foreign key
Name >>>> string Course >>> string
Surname >>> string Semester >>> number
Gender >>>string Grade >>> string

Integrity Rules
1.It must be allowed to insert ”Female” and “Male” into “Gender “only.

2.”PT” is parent table and “CH” is child table.

3-Only uppercase data can be inserted to name and surname.

4-Create a sequence for Id in Table “PT”.

5-Semester can have 1 and 2 only.

6-”Grade” can have A , A- , B , B+ ,B- , C ,C+,C-, D, D+ , F

7-Gender can not be null.

8-On the table CH : Id, Course and semester must be unique together. Each student must have one row
for a course in a semester.

Example :
id Course Semester
------------------------------------
1 MATH 1 >>>> POSSIBLE
1 MATH 2 >>>> POSSIBLE
1 MATH 1 >>>> IMPOSSIBLE

9-Insert the following rows into tables above. Find the 4 errors while inserting following rows.

PT CH
ID NAME SURNAME GENDER ID COURSE SEMESTER GRADE
1 ADIL NUSIPOV MALE 1 CS200 1 F+
2 JAZIRA NUROVA FEMALE 2 INF100 3 A
4 AYNUR SAPAR EMALE 3 MATH 1 A-

10-Delete the first row from “PT”. Why can not you delete it?
B-Create a sequence name is MySequence with the following parameters.
Starting values : 25
Minimum Value : 10
Maximum Value : 100
Step : 3

1- Disable MySequence and see that it does not work.

2-Enable MySequence and see that it can work.

3-Can you know the current value of MySequence?

C-Create the following table and insert rows in below.

Library
Book_id >>>> String Book_id Student_id Taken_date Given_date
Student_id >>>> number
Taken_date >>>> date AB102 10 12/05/08 05/06/08
Given_date >>>> date CT201 20 04/02/08 06/09/09

Rule
3.1-The default value of Taken_date is sysdate: It means, sysdate value is inserted into Taken_date if
any date is not inserted.

3.2- Students must pay 10 Tenge per each day. Write a query which will display students with reading
day and paid money.

Example :

Student_id Day paid


----------------------------------
10 24 240
20 580 5800

KENAN CETINKAYA
5-MAR-2009
SDU

You might also like