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 (
CourseCode VARCHAR(10) PRIMARY KEY,
CourseName VARCHAR(255)
);
-- Insert data into Course table
INSERT INTO Course (CourseCode, CourseName) VALUES
('BCS092', 'Introduction to Programming'),
('DBMS101', 'Database Management Systems'),
_______ _____ _______ ____ ______ ______ _________ ____ ________.
__________ ____ __________ _________ __________ ______ __________ ____ __________.
________ ______ __________ _________ __________ ______ __________ ______ _______ _____ ______.
____ ____ _________ ______ _______.
________ __________ ___ _____ _________ ______ ______ ___ ___.
________ ___ ________ _____ __________ _______ ______ ______ _________.
______ _____ __________ _______ __________ ____ ____ _____ _____ __________ _______ _______.
_____ _____ ____ ___ _____ _________ _______ __________ ________ _________ ___.
_________ _____ _____ _______ ______.
___ _______ _______ ________ _______ _______ ____ _______.
___ ___ _____ ____ _______.
__________ ________ ___ __________ ____ ___ _______ ____ __________ __________ _________.
_______ ____ __________ ________ ________ __________ __________ ____ __________ _____.
__________ ____ _______ ___ ___ _________ ______ ____ _______ _______ ________ _________.
______ ______ _________ ______ ________ ___ ____ ________ __________.
_______ _______ ___ __________ ___ _________ ____.
_______ ___ ___ _________ ___ ______ ___ ________ _____ ____.
_____ ______ _______ _________ __________ ____ ____ ____.
__________ _______ _____ _______ _____.
__________ _______ ___ _______ _____.
________ ______ ____ _______ _________ __________ _____ ______ ____.
_______ ___ _______ _______ _________ _________ ___.
___ __________ _____ _________ ___ ______ ____ ____.
______ ____ ______ ______ _______ _____.
__________ _____ __________ ______ __________ ____.
______ _______ ________ ________ __________ ___ _____.
________ _______ ____ ____ _________.
_____ __________ _____ _______ _____ _________ ________ _________ __________ _________ _________.
____ ______ ________ ______ ___ _____.
______ __________ _______ _______ _________ ____ _________ _________ __________ _______ _________ _______.
________ ________ _________ _____ ________ ___ ______ ___ _________ __________ __________.
_______ _____ ________ ________ _______ _________.
___ ____ ______ ___ ___.
_______ ___ _____ ______ ________ __________ _________ _____ ____.
_________ ________ _______ _______ __________ ____ ________.
______ __________ _________ __________ __________ __________ __________ _____.
_____ _______ ___ _______ ______ _______.
_____ ________ ______ __________ _______ _________ ______ _____ ________.
________ ________ ___ _______ ___ __________ _________ ___.
____ __________ ________ ____ ___ ______ ______ _______ _____.
_______ ________ ___.
- Solved Assignments
- Study Notes
- Guess Papers
- Question Papers
✓ Unlock up to 60% of the answer
✓ No payment required