You are on page 1of 1

1.

Create a table named Student_<student_id> in the database with the following columns
● StuId NUMERIC(12),
● StuName CHAR(50)
● CourseId INT
● StatusId INT
● BatchId INT

2. Create three tables:


● Course_<student_id> (CourseId INT, CourseName VARCHAR(100)). CourseId is the
primary key.
● Batch_<student_id> (BatchId INT, BatchName VARCHAR(100)). BatchId is the primary key.
● StudentStatus_<student_id> (StatusId INT, StatusDesc VARCHAR(100). StatusId is the
primary key.

3. Create foreign key constraints on the following columns of Student_<student_id> table:


● CourseId -- references to CourseId of Course_<student_id> with ON UPDATE SET NULL
option. The foreign key name should be FK_Stu_Course_CourseId_<student_id>.

● BatchId -- references to BatchId of Batch_<student_id> with ON DELETE CASCADE


option. The foreign key name should be FK_Stu_Batch_BatchId_<student_id>.

● StatusId -- references to StatusId of StudentStatus_<student_id>. The foreign key name


should be FK_Stu_Status_StatusId_<student_id>.

4. Insert 3 records in each of the four tables: Student_<student_id>, Course_<student_id> ,


Batch_<student_id> , StudentStatus_<student_id>.

5. Write a Select query to retrieve the StuId and StuName details of all the students who are
studying the course ‘B.Tech’ with status ‘Active’ and are part of the batch ‘BCS3B’.

You might also like