Consider the following relational schema:
Student (Sid, Sname, ProgCode, DateofAdmission) – Sid is the student id (Primary Key) which is a unique identifier assigned by the University when the student takes admission into a Programme, Sname is the student name, ProgCode identifies the programme in which the student has taken admission (Foreign Key), DateofAdmission is the date when the student took admission.
Course (CourseCode, CourseName)– CourseCode is the name of the course and is the Primary Key, CourseName is the name of the course. Result (Sid, CourseCode, ExaminationDate, Marks) –Sid is the student id, CourseCode is the
identifier of the course or subject in which the student has taken admission (Sid + Coursecode are the composite Primary Key; please also note Sid is a foreign key that references Student relation and CourseCode is a foreign key that references the Course relation), ExaminationDate is the date of examination, Marks is the marks out of 100 in that examination.
(a) Create the tables using SQL for the schema given above; you must include the Primary key, foreign keys and constraints in your implementation. Enter a few sets of meaningful data in each table.
(b) Write and run SQL statements for the following queries:
(i) List the names of all the students who have been admitted to CMAD after 31st
December 2023.
(ii) List the names of all the students who have appeared for the examination of the
course whose code is “BCS092”.
(iii) Find the list of courses in which a student whose Sid is “2310009487” passed.
Assume that the minimum marks for passing a course is 40.
(iv) List the student ID and the student's name who has passed at least five courses.
(v) Find the total number of Programmes.
(vi) Find the total number of students who have appeared for the examination of the
course named “DBMS”.
Note: Make suitable assumptions, if any
(a) SQL Schema and Data Insertion:
```sql
-- Create Student table
CREATE TABLE Student (
Sid INT PRIMARY KEY,
Sname VARCHAR(255),
ProgCode INT,
DateofAdmission DATE,
FOREIGN KEY (ProgCode) REFERENCES Programme(ProgCode)
);
-- Insert data into Student table
INSERT INTO Student (Sid, Sname, ProgCode, DateofAdmission) VALUES
(2310009487, 'John Doe', 1, '2023-01-15'),
(2310009488, 'Jane Smith', 2, '2024-02-20'),
(2310009489, 'Alice Johnson', 1, '2023-06-10');
-- Create Course table
CREATE TABLE Course (
_______ ____ __________ _______ ________ _________ _____ ______ ________ _______ ______ _____.
____ ____ ____ _________ ____ ___ ___.
_____ ________ ______ _______ ___ _______ _____.
________ ______ _______ _________ _____ __________.
___ ______ _________ _________ ________ _________ _____.
______ _________ _____ ______ ____.
____ _______ ________ _______ ______ __________ _________ _______ __________ _______.
_________ _______ ____ ___ _______ ___ ______ _____ ______ _______ __________ ______.
_____ ___ ____ _______ ____ __________.
_________ _______ ____ __________ ______ __________ ____ ____.
_____ ________ _____ _______ _____ ___ _____.
_______ _______ ________ _________ _________ _______.
____ ________ _________ __________ ___.
_________ _____ ______ _______ _______.
____ _______ _______ ____ __________ ____ _______ _____ __________ _______ _______ _____.
___ _______ ___ ________ _________ ______ _________ ____.
____ ______ ___ _______ _________ _____ ________ ___.
_____ ______ _________ ___ _____ _________ ________ ____ ______.
______ ________ _______ ____ __________ _________.
____ _____ __________ _______ ____ _______ ____ _________ _________ ____ ____.
_______ _________ ____ ___ ___ _________ ____ ___.
_____ _________ _______ ____ _____ ________.
____ _________ __________ ___ _________ _____ ___ _____ ________ __________.
_______ _______ ____ _____ _____ _____ ____ __________ ______ ______.
____ ____ ___ ___ ____ __________ ___ ____ _______ _______ _____.
________ ___ _________ _______ ______ __________ _______ ____.
______ _______ ______ _____ ________ __________ _____ ____ _________ ______ ___ ___.
_________ ________ ____ __________ ________ ___ _________ ____ ______ ________ _______.
__________ ____ __________ _________ ________ ____ ______ _______ _____ __________ __________ ____.
______ ___ __________ ______ __________.
____ __________ _______ ______ _______ ___.
__________ ___ _______ ________ ____ _________ _________ ___ _________ _________ ______.
________ _________ __________ _______ _______ _____ _____ _________ ____.
___ ___ _____ _________ _________ _______ ____.
______ ____ _________ ______ _____ _____ __________.
______ __________ ____ __________ _____ ________ _________ _____ ____ ____.
__________ __________ ____ __________ __________ ____ ____ _____ ____.
______ ________ ____ _____ ___ ________ ___ __________.
_____ ___ ___ ________ __________.
________ ____ __________ ________ ____ _______.
_________ ____ ______ _______ ______ ________ __________ _________ ____ _____ ___ ____.
______ ________ ________ ___ __________ _____.
___ ____ ____ _________ ___ _______.
_______.
Get Full Answer on WhatsApp