0% found this document useful (0 votes)
3 views20 pages

Csc Data Base Assignment

The document provides SQL queries for various tasks related to a university and insurance database, including finding course titles, student IDs, staff salaries, and accident involvement. It includes the creation of tables, insertion of data, and specific SELECT statements to retrieve information. Additionally, it covers adding and deleting records from the database, as well as creating new courses and sections.

Uploaded by

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

Csc Data Base Assignment

The document provides SQL queries for various tasks related to a university and insurance database, including finding course titles, student IDs, staff salaries, and accident involvement. It includes the creation of tables, insertion of data, and specific SELECT statements to retrieve information. Additionally, it covers adding and deleting records from the database, as well as creating new courses and sections.

Uploaded by

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

CSC/22D/4472

1. Write the following queries in SQL, using the university schema.


A. find the title of courses in computer science department that have 3 credit units?

• The first picture shows the complete data entered while the other picture shows the output after
performing a query to find the title of courses in computer science department that have 3 credit units,
which only shows the title of courses in computer science department that have 3 credit units.
➢ CODE
CREATE TABLE Course (
CourseCode INT PRIMARY
KEY, CourseTitle
VARCHAR(50), CourseUnit
INT,
Department VARCHAR(50)
);
INSERT INTO Course (CourseCode, CourseTitle, CourseUnit, Department) VALUES
(303, 'COMPUTER ARCHITECTURE', 3, 'COMPUTER SCIENCE'),
(307, 'STRUCTURED AND OBJECT ORIENTED PROGRAMMING', 3, 'COMPUTER
SCIENCE'), (311, 'SYSTEM ANALYSIS AND DESIGN', 3, 'COMPUTER SCIENCE'),
(313, 'ORGANIZATION OF PROGRAMMING LANGUGES', 3, 'COMPUTER
SCIENCE'), (315, 'DATABAASE DESIGN AND MANAGEMENT', 3, 'COMPUTER
SCIENCE'),
(317, 'COMPUTATIONAL SCIENCE AND NUMERICAL METHOD', 3, 'COMPUTER
SCIENCE'), (301, 'INTRODUCTION TO ENTREPRENEURIAL STUDIES', 2, 'GENERAL
STUDIES');
SELECT * FROM Course;
SELECT CourseTitle FROM Course WHERE Department = 'COMPUTER SCIENCE' AND CourseUnit = 3;
B. Find the IDs of all students who were taught by a staff named Einstein?


The first picture shows the complete data entered which is a list of studentIDs, StudentName and StaffName
while the other picture shows the output after performing a query to Find the IDs of all students who were
taught by a staff named Einstein, which only shows the IDs of all the student who were taught by a staff named
Einstein.
➢ CODE
CREATE TABLE Student (
StudentID INT PRIMARY
KEY,
StudentName VARCHAR(50),
StaffName VARCHAR(50)
);
INSERT INTO Student (StudentID, StudentName, StaffName) VALUES
(3167, 'OLIVER AYUBA', 'EINSTEIN'),
(3072, 'PAUL LUKA', 'AFOLABI'),
(3074, 'THOMAS LYNN', 'AFOLABI'),
(3020, 'MUJAHEED MUSA',
'NASIRU'), (4434, 'ISAAC BILTON',
'EINSTEIN'),
(4458, 'ABDULRASHEED HASSAN', 'EINSTEIN'),
(4443, 'ISMAIL MAFINDI', 'EINSTEIN'),
(4462, 'AUWAL LADO', 'EINSTEIN'),
(3976, 'AUGUSTINA DANIEL',
'EINSTEIN'), (3021, 'KAMILU
MOHAMMED', 'NASIRU'),
(4485, 'ABDULRAHAM MOHAMMED', 'EINSTEIN');
SELECT * FROM Student;
SELECT StudentID FROM Student WHERE StaffName = 'EINSTEIN';
C. Find the highest salary of any staff.

• The first picture shows the complete data entered which is a list of Staff and their Salary while the other
picture shows the output after performing a query to Find the highest salary of any staff, which only shows the
highest salary.
➢ CODE
CREATE TABLE Staff (
StaffID INT PRIMARY
KEY,
StaffName VARCHAR(50),
StaffSalary
DECIMAL(10,2)
);
INSERT INTO Staff (StaffID, StaffName, StaffSalary)VALUES
(2130, 'AYUBA OLIVER', 450000.00),
(1130, 'MAXWELL BITRUS', 120000.00),
(0131, 'JOHN JOSEPH', 160000.00),
(2160, 'ALICE PETER', 200000.00),
(4130, 'ERDOO DANIEL', 100000.00),
(2440, 'LYNN LUKA', 330000.00),
(0130, 'PAUL THOMAS', 210000.00),
(1120, 'HASSAN AHMAD', 140000.00),
(3410, 'MAJAHEED MAFINDI', 400000.00),
(0030, 'AISHA KAMILU',
350000.00); SELECT * FROM Staff;
SELECT MAX(StaffSalary) AS highest_salary FROM staff;
SELECT * FROM staff WHERE StaffSalary = (SELECT MAX(StaffSalary) FROM staff);
D. Find all staffs earning the highest salary

• This picture shows the output after performing another query on that same data to Find all staffs earning the
highest salary, which shows a list of only two staff that are earning the highest salary.
➢ CODE
INSERT INTO Staff (StaffID, StaffName, StaffSalary)VALUES
(4230, 'SABASTINE JANE', 400000.00),
(4530, 'MUSA ISA', 450000.00);
SELECT * FROM staff WHERE StaffSalary = (SELECT MAX(StaffSalary) FROM staff);

E. Find the enrollment of each section that was offered in Autumn 2009.

• The first picture shows the complete data entered which is a list of semesters, Year and their section while
the other picture shows the output after performing a query to Find the enrollment of each section that was
offered in Autumn 2009, which only shows the number of enrollment and the SectionIDs that were offered in
Autumn 2009.
➢ CODE
CREATE TABLE StudentEnrollment (
SectionID INT PRIMARY KEY,
Semester VARCHAR(20),
Year INT
);
INSERT INTO StudentEnrollment (SectionID, Semester, Year) VALUES (3,
'AUTUMN', 2009),
(2, 'AUTUMN', 2008),
(1, 'AUTUMN', 2009),
(5, 'AUTUMN', 2009),
(4, 'AUTUMN', 2010);
SELECT * FROM StudentEnrollment;
SELECT SectionID, COUNT(*) AS enrollment FROM StudentEnrollment WHERE Semester = 'AUTUMN' AND
year = 2009
GROUP BY SectionID;

F. Find the maximum enrollment across all sections, in Autumn 2009.


This picture shows the output after performing another query on that same data to Find the maximum
enrollment, across all sections, in Autumn 2009, which shows only the maximum enrollment.
➢ CODE
SELECT MAX(enrollment) AS max_enrollment
FROM (
SELECT COUNT(*) AS enrollment FROM StudentEnrollment WHERE Semester = 'AUTUMN' AND Year = 2009
GROUP BY SectionID
) AS enrollments_per_section;
G. Find the sections that had the maximum enrollment in Autumn 2009.


This picture shows the output after performing another query on that same data to Find the sections that had
the maximum enrollment in Autumn 2009, which shows all the sections with maximum enrollment in
Autumn 2009.
➢ CODE
SELECT SectionID, COUNT(*) AS enrollment FROM StudentEnrollment WHERE Semester = 'AUTUMN' AND
Year = 2009
GROUP BY SectionID
HAVING COUNT(*)
=(
SELECT MAX(enrollment)
FROM (
SELECT COUNT(*) AS
enrollment FROM
StudentEnrollment
WHERE Semester = 'AUTUMN' AND Year = 2009
GROUP BY SectionID
) AS enrollments_per_section
);

2. Consider the insurance database of Figure 3.18, where the primary keys are underlined. Construct the
following SQL queries for this relational database.
A. Find the total number of people who owned cars that were involved in accidents in 2009.
• The first picture shows the complete data entered while the other picture shows the output after performing a
query to Find the total number of people who owned cars that were involved in an accident in 2009, which
only shows the total number of people owned cars and involved in an accident in 2009.
➢ CODE
CREATE TABLE Person (
DriverID INT PRIMARY
KEY, Name VARCHAR(50),
Address VARCHAR(255)
);
INSERT INTO Person (DriverID, Name, Address) VALUES
(001, 'oliver simon', 'jimeta'),
(002, 'john thom', 'kebbi'),
(003, 'chris tyne', 'yorro'),
(004, 'isaac bonny', 'jimeta'),
(005, 'ello ken', 'yola'),
(006, 'doe jek', 'jimeta'),
(007, 'hilly muon', 'yola'),
(008, 'type sick', 'yola'),
(009, 'rice men', 'girei');
CREATE TABLE Car (
License INT PRIMARY
KEY, Model VARCHAR(50),
Year INT
);
INSERT INTO Car (License, Model, Year)
VALUES (0012, 'TOYOTA', 2009),
(0022, 'VENZA', 2006),
(0032, 'BENZ', 2009),
(0042, 'HONDA', 2000),
(0052, 'HIGHLANDA', 2004),
(0062, 'PRADO', 2009),
(0072, 'TOYOTA', 2008),
(0082, 'PEUGEOT', 2009),
(0092, 'TOYOTA', 2003);
CREATE TABLE Accident (
ReportNumber INT PRIMARY
KEY, date DATE,
Location VARCHAR(255)
);
INSERT INTO Accident (ReportNumber, date, Location) VALUES
(00133, '2009-02-20', 'jimeta'),
(00233, '2008-07-23', 'kebbi'),
(00333, '2009-02-20', 'yorro'),
(00433, '2009-06-29', 'jimeta'),
(00533, '2009-07-30', 'yola'),
(00633, '2008-08-27', 'jimeta'),
(00733, '2009-04-04', 'yola'),
(00833, '2007-02-09', 'yola'),
(00933, '2009-02-25', 'girei');
CREATE TABLE Owns (
DriverID INT PRIMARY
KEY,
License INT
);
INSERT INTO Owns (DriverID, License) VALUES
(001, 0012),
(002, 0022),
(003, 0032),
(004, 0042),
(005, 0052),
(006, 0062),
(007, 0072),
(008, 0082),
(009, 0092);
CREATE TABLE Participated (
ReportNumber INT PRIMARY
KEY, License VARCHAR(255),
DriverID INT,
DamageAmount DECIMAL (10,2)
);
INSERT INTO Participated (ReportNumber, License, DriverID, DamageAmount) VALUES
(0013, 0012, 001, 5000.00),
(0033, 0022, 002, 60000.00),
(0043, 0032, 004, 67000.00),
(0053, 0042, 007, 80000.00);
SELECT * FROM Person, Car, Accident, Owns, Participated;
SELECT COUNT(DISTINCT p.DriverID) AS total_people_involved
FROM Person p
INNER JOIN Owns o ON p.DriverID = o.DriverID
INNER JOIN Participated pt ON o.License = pt.License
INNER JOIN Accident a ON pt.ReportNumber = a.ReportNumber
WHERE YEAR(a.date) = 2009;

B. Add a new accident to the database; assume any values for required attributes.

• This picture shows the output after performing another query on that same data to add a new accident to the
database, which shows only the report number, date and location of the newly added accident.
➢ CODE
INSERT INTO Accident (ReportNumber, date, Location)
VALUES (001033, '2024-04-01', 'sangere');
SELECT * FROM Accident;

C. Delete the Mazda belonging to “John Smith”.

• The first picture shows the complete data entered while the other picture shows the output after performing a
query to delete the Mazda belonging to “John Smith”.
➢ CODE
CREATE TABLE branch (
branch_name VARCHAR(100),
branch_city VARCHAR(100),
assets DECIMAL(10, 2),
PRIMARY KEY
(branch_name)
);
INSERT INTO branch (branch_name, branch_city, assets) VALUES
('yoolla branch', 'yola', 500000.00),
('gireii branch', 'gire', 450000.00),
('Mazda', 'girei', 450000.00);
CREATE TABLE customer (
customer_name VARCHAR(100),
customer_street VARCHAR(255),
customer_city VARCHAR(100),
PRIMARY KEY (customer_name)
);
INSERT INTO customer (customer_name, customer_street, customer_city) VALUES ('oliver
ayubas', 'sabon gari street', 'jalingo'),
('thomas lynnn', 'mile sx street', 'jalingo'),
('john smith', 'mau street', 'yola'); CREATE
TABLE loan (
loan_number INT
AUTO_INCREMENT, branch_name
VARCHAR(100), amount
DECIMAL(10, 2),
PRIMARY KEY (loan_number),
FOREIGN KEY (branch_name) REFERENCES branch(branch_name)
);
INSERT INTO loan (loan_number, branch_name, amount) VALUES
(001, 'gireii branch', 50000.00),
(002, 'yoolla branch', 250000.00),
(003, 'Mazda', 200000.00);
CREATE TABLE borrower (
customer_name VARCHAR(100),
loan_number INT,
PRIMARY KEY (customer_name, loan_number),
FOREIGN KEY (customer_name) REFERENCES customer(customer_name), FOREIGN
KEY (loan_number) REFERENCES loan(loan_number)
);
INSERT INTO borrower (customer_name, loan_number) VALUES
('oliver ayubas', 001),
('thomas lynnn', 002),
('john smith', 003);
CREATE TABLE account
(
account_number INT
AUTO_INCREMENT, branch_name
VARCHAR(100),
balance DECIMAL(10, 2),
PRIMARY KEY
(account_number),
FOREIGN KEY (branch_name) REFERENCES branch(branch_name)
);
INSERT INTO account (account_number, branch_name, balance) VALUES
(111222, 'yoolla branch', 30000.00),
(112233, 'gireii branch', 25000.00),
(223344, 'Mazda', 80000.00);
CREATE TABLE depositor (
customer_name VARCHAR(100),
account_number INT,
PRIMARY KEY (customer_name, account_number),
FOREIGN KEY (customer_name) REFERENCES customer(customer_name), FOREIGN
KEY (account_number) REFERENCES account(account_number)
);
INSERT INTO depositor (customer_name, account_number) VALUES
('oliver ayubas', 111222),
('thomas lynnn', 112233),
('john smith', 223344);
SHOW TABLES;
SELECT * FROM branch, customer, loan, borrower, account, depositor;
SELECT account_number FROM account WHERE branch_name = 'Mazda';programsProgramID
DELETE FROM depositor WHERE account_number IN (SELECT account_number FROM account WHERE branch_name =
'Mazda');
DELETE FROM account WHERE branch_name = 'Mazda';
3. Write the following queries in SQL, using the university schema.
A. Create a new course “CS-001”, titled “Weekly Seminar”, with 0 credits.

• This picture shows the output after creating a new course “CS-001”, titled “Weekly Seminar”, with 0 credits.
➢ CODE
CREATE TABLE Course (
CourseCode
VARCHAR(10), CourseTitle
VARCHAR(50), CourseUnit
INT,
PRIMARY KEY (CourseCode)
);
INSERT INTO Course (CourseCode, CourseTitle, CourseUnit) VALUES
('CS-001', 'Weekly Seminar', 0);
SELECT * FROM Course;

B. Create a section of this course in Autumn 2009, with sec id of 1.

• This picture shows the output after creating a section of this course in Autumn 2009, with sec id of 1.
➢ CODE
CREATE TABLE Section (
CourseCode
VARCHAR(10), SectionID
INT,
Semester VARCHAR(50),
Year INT,
PRIMARY KEY (CourseCode)
);
INSERT INTO Section (CourseCode, SectionID, Semester, Year) VALUES
('CS-001', 1, 'AUTUMN', 2009);
SELECT * FROM Section;

C. Enroll every student in the Comp. Sci. department in the above section.

• This picture shows the output after enrolling every student in Comp. Sci. department in the above section.
➢ CODE
CREATE TABLE student (
StudentID INT PRIMARY
KEY,
StudentName VARCHAR(50),
Gender VARCHAR(10),
DeptName VARCHAR(100)
);
INSERT INTO student (StudentID, StudentName, Gender, DeptName) VALUES
(3167, 'OLIVER', 'male', 'Computer Science'),
(3166, 'JESSE', 'male', 'Computer Science'), (3165,
'ERDOO', 'female', 'Computer Science'), (3164,
'OLIVE', 'female', 'Computer Science'), (3163,
'Chavez', 'male', 'Computer Science'), (3162,
'JENESTY', 'female', 'Computer Science'), (3161,
'GEORGE', 'male', 'Computer Science'), (3160,
'LYNN', 'male', 'Computer Science'), (3159,
'LOUIS', 'female', 'Computer Science'), (3158,
'JOY', 'female', 'Computer Science');

CREATE INDEX section_index ON section (CourseCode, SectionID, Semester, Year);


CREATE TABLE enroll (
StudentID INT, CourseCode
VARCHAR(10), SectionID
INT,
Semester VARCHAR(20),
Year INT,
grade VARCHAR(2),
PRIMARY KEY (StudentID, CourseCode, SectionID, Semester, Year),
FOREIGN KEY (StudentID) REFERENCES student(StudentID),
FOREIGN KEY (CourseCode, SectionID, Semester, Year) REFERENCES section(CourseCode, SectionID, Semester, Year)
);
CREATE TABLE department (
DeptName VARCHAR(100) PRIMARY KEY
);
INSERT INTO department (DeptName) VALUES
('Computer Science'),
('Mathematics'),
('Physics'),
('statistics');

INSERT INTO enroll (StudentID, CourseCode, SectionID, Semester, Year)


SELECT s.StudentID, 'CS-001', 1, 'AUTUMN', 2009
FROM student s
JOIN department d ON s.DeptName = d.DeptName
WHERE d.DeptName = 'Computer Science';

D. Delete enrollments in the above section where the student’s name is Chavez.

• This picture shows the output after deleting all the enrollments in the above section where the student’s name
is Chavez.
➢ CODE
DELETE FROM enroll
WHERE StudentID IN (SELECT StudentID FROM student WHERE StudentName = 'Chavez')
AND CourseCode = 'CS-001'
AND SectionID = 1
AND Semester =
'AUTUMN' AND Year =
2009;

E. Delete the course CS-001. What will happen if you run this delete statement without first deleting
offerings (sections) of this course.

.
• This picture shows the output after deleting the course CS-001.
• If you attempt to delete the course "CS-001" without first deleting the offerings (sections) of this course, you
will likely encounter a foreign key constraint violation error. This error occurs because there is a foreign key
relationship between the `Section` table and the `enroll` table, where the `CourseCode` column in the
`Section` table references the `CourseCode` column in the `enroll` table.
➢ CODE
DELETE FROM enroll
WHERE CourseCode = 'CS-001';

DELETE FROM Section


WHERE CourseCode = 'CS-001';

DELETE FROM Course


WHERE CourseCode = 'CS-001';
F. Delete all takes tuples corresponding to any section of any course with the word “database” as a
part of the title.

• This picture shows the output after deleting all takes tuples corresponding to any section of any course with
the word “database” as a part of the title.
➢ CODE
DELETE FROM enroll
WHERE CourseCode IN (
SELECT CourseCode
FROM course
WHERE LOWER(CourseTitle) LIKE '%database%'
);

4. Write the following queries in SQL, using the university schema.


A. Find the names of all students who have taken at least one Comp. Sci. course; make sure there are
no duplicate names in the result.

• The first picture shows the complete names of student entered with their respective courses while the other
picture shows the output after performing a query to Find the names of all students who have taken at least one
Computer Science. course, which only shows the names of students who have taken at least one Computer
Science course.
➢ CODE
CREATE TABLE student (
StudentID INT PRIMARY
KEY,
StudentName VARCHAR(50),
CourseCode VARCHAR(10),
Semester VARCHAR(50), Year
INT
);
CREATE TABLE department (
CourseCode VARCHAR(10),
PRIMARY KEY
(CourseCode)
);
INSERT INTO department (CourseCode) VALUES
('CSC315'),
('CSC311'),
('CSC317'),
('CSC313'),
('CSC307'),
('CSC303');
INSERT INTO student (StudentID, StudentName, CourseCode, Semester, Year) VALUES (3137,
'oliver', 'CSC315', 'spring', 2009),
(3127, 'LYNN', 'OPR315', 'spring', 2008),
(3197, 'oliv', 'CSC317', 'spring', 2006),
(3163, 'LADO', 'CSC311', 'AUTUMN', 2009),
(3166, 'COLLINS', 'CSC313', 'AUTUMN', 2010),
(3164, 'MUJAHID', 'STA315', 'spring', 2009),
(3160, 'oliver', 'CSC315', 'AUTUMN', 2019),
(3154, 'JENESTY', 'MTH317', 'spring', 2009),
(3120, 'ERDOO', 'CSC313', 'AUTUMN', 2008),
(3117, 'GLORY', 'PHY315', 'spring', 2009),
(3107, 'KENNETH', 'CSC307', 'AUTUMN', 2009);

SELECT DISTINCT s.StudentName


FROM student s
JOIN department d ON s.CourseCode = d.CourseCode
WHERE d.CourseCode LIKE 'CSC%';
B. Find the IDs and names of all students who have not taken any course offering before Spring 2009.


This picture shows the output after performing another query on that same data to find the IDs and names of
all students who have not taken any course offering before Spring 2009, which shows the IDs and names of
only those students who have not taken any course offering before Spring 2009.
➢ CODE
SELECT DISTINCT s.StudentID, s.StudentName
FROM student s
LEFT JOIN department d ON s.CourseCode = d.CourseCode WHERE
s.Year >= 2009 AND s.Semester NOT LIKE 'Spring';

C. For each department, find the maximum salary of staffs in that department. You may assume that
every department has at least one staff.

• The first picture shows the complete list of staff entered while the other picture shows the output after
performing a query for each department to find the maximum salary of staffs in that department, which only
shows the department name with their maximum salary respectively.
➢ CODE
CREATE TABLE department (
DeptName VARCHAR(100) PRIMARY KEY
);
INSERT INTO department (DeptName) VALUES
('Computer Science'),
('Mathematics'),
('Statistics'),
('Operation Research');
CREATE TABLE staff (
StaffID INT PRIMARY
KEY,
StaffName VARCHAR(100),
DeptName VARCHAR(100),
Salary DECIMAL(10, 2),
FOREIGN KEY (DeptName) REFERENCES department(DeptName)
);
INSERT INTO staff (StaffID, StaffName, DeptName, Salary) VALUES
(0101, 'oliver ayuba', 'Computer Science', 400000.00),
(0102, 'Isaac Bilton', 'Computer Science', 200000.00),
(0103, 'Zainab musa', 'Mathematics', 255000.00),
(0104, 'Mujahid Musa', 'Statistics', 358000.00),
(0105, 'Thomas Lynn', 'Operation Research', 242000.00),
(0106, 'Auwal Lado', 'Computer Science', 260000.00),
(0107, 'Paul Luka', 'Operation Research', 262000.00),
(0108, 'Kamilu Mohammed', 'Statistics', 350000.00),
(0109, 'Mathias Boniface', 'Mathematics', 155000.00);
SELECT d.DeptName, MAX(staff.Salary) AS MaxSalary
FROM department d
JOIN staff ON d.DeptName = staff.DeptName
GROUP BY d.DeptName;

D. Find the lowest, across all departments, of the per-department maximum salary computed by the
preceding query.

• This picture shows the output after performing another query on that same data to find the lowest, across all
departments, of the per-department maximum salary computed by the preceding query.
➢ CODE
SELECT MIN(MaxSalary) AS LowestMaxSalary
FROM (
SELECT MAX(staff.Salary) AS MaxSalary
FROM department d
JOIN staff ON d.DeptName = staff.DeptName
GROUP BY d.DeptName
) AS MaxSalaries;

5. Prepare table with the following SQL of 20 student record of your choice using student data in a
university
schema:
CREATE TABLE Students (
StudentID INT PRIMARY KEY,
FirstName VARCHAR(50),
LastName VARCHAR(50),
DateOfBirth DATE,
Gender VARCHAR(10),
Email VARCHAR(100),
Phone VARCHAR(20),
Address VARCHAR(255),
City VARCHAR(100),
State VARCHAR(50),
ZipCode VARCHAR(20),
Country VARCHAR(100),
ProgramID INT,
FOREIGN KEY (ProgramID) REFERENCES Programs (ProgramID)
);

• This picture shows the output after preparing table and entering record of 20 students.
➢ CODE
CREATE TABLE Programs (
ProgramID INT PRIMARY
KEY,
ProgramName VARCHAR(100),
ProgramDescription TEXT
);
INSERT INTO Programs (ProgramID, ProgramName, ProgramDescription)VALUES
(1, 'Computer Science', 'This program covers various aspects of computer science.'), (2,
'Mathemtics', 'This program focuses on calculations.'),
(3, 'statistics', 'This program covers data analysis.'),
(4, 'operation research', 'This program focuses research.');
CREATE TABLE Students (
StudentID INT PRIMARY KEY,
FirstName VARCHAR(50),
LastName VARCHAR(50),
DateOfBirth DATE,
Gender VARCHAR(10),
Email VARCHAR(100),
Phone VARCHAR(20),
Address VARCHAR(255),
City VARCHAR(100),
State VARCHAR(50),
ZipCode VARCHAR(20),
Country VARCHAR(100),
ProgramID INT,
FOREIGN KEY (ProgramID) REFERENCES Programs (ProgramID)
);
INSERT INTO Students (StudentID, FirstName, LastName, DateOfBirth, Gender, Email, Phone, Address, City, State, ZipCode, Country, ProgramID)
VALUES
(001, 'Oliver', 'Ayuba', '1997-05-15', 'Male', '[email protected]', '08163137391', 'No43 Sabon gari str', 'Jalingo', 'Taraba', '660213', 'Nigeria', 1),
(002, 'thomas', 'Lynn', '1994-04-25', 'Male', '[email protected]', '09130251023', 'No40 mile six str', 'Jalingo', 'Taraba', '660013', 'Nigeria', 4),
(003, 'Abdulrashid', 'Hassan', '1991-02-05', 'Male', '[email protected]', '08166774599', 'No23 Iware str', 'Ardokola', 'Taraba', '660203', 'Nigeria', 1),
(004, 'Paul', 'Luka', '1997-01-10', 'Male', '[email protected]', '08059784637', 'No59 FGGC str', 'Jalingo', 'Taraba', '640013', 'Nigeria', 4),
(005, 'Bilton', 'Isaac ', '1990-08-10', 'Male', '[email protected]', '07035947861', 'No34 Gullum str', 'Jalingo', 'Taraba', '690293', 'Nigeria', 1),
(006, 'Mujahid', 'Musa', '1992-06-05', 'Male', '[email protected]', '08095846712', 'No20 Iware str', 'Ardokola', 'Taraba', '630293', 'Nigeria', 3),
(007, 'Kamilu', 'Muhammed', '1998-07-14', 'Male', '[email protected]', '09045758468', 'No26 samunaka str', 'Jalingo', 'Taraba', '651213', 'Nigeria', 3),
(008, 'Bitrus', 'Ayuba', '2000-01-12', 'Male', '[email protected]', '08125588554', 'No13 galili str', 'gombi', 'Adamawa', '560013', 'Nigeria', 2),
(009, 'Ismail', 'Mafindi', '1995-01-01', 'Male', '[email protected]', '08045547447', 'No44 mafindi str', 'Gassol', 'Taraba', '460213', 'Nigeria', 1),
(010, 'Jenesty', 'Ayuba', '1994-08-08', 'Female', '[email protected]', '08175849685', 'No65 Shavon str', 'Jalingo', 'Taraba', '680211', 'Nigeria', 2),
(011, 'Erdoo', 'Daniel', '2000-04-19', 'Female', '[email protected]', '09056987432', 'No73 lynn str', 'Jalingo', 'Taraba', '660219', 'Nigeria', 1),
(012, 'Auwal', 'Lado', '2004-06-12', 'Male', '[email protected]', '07058496718', 'No49 tashun str', 'Gombi', 'Adamawa', '690210', 'Nigeria', 1),
(013, 'Fatima', 'Abubakar', '1999-08-15', 'Female', '[email protected]', '08133225566', 'No31 farnsa str', 'Mubi', 'Adamawa', '680212', 'Nigeria', 3),
(014, 'Samuel', 'Joel', '1999-08-08', 'Male', '[email protected]', '080259976419', 'No67 kella str', 'Makurdi', 'Benue', '450213', 'Nigeria', 4),
(015, 'Grace', 'John', '2003-02-02', 'Female', '[email protected]', '07069896859', 'No13 Sabuna str', 'girei', 'Adamawa', '600203', 'Nigeria', 4),
(016, 'Deborah', 'Peter', '1991-12-15', 'female', '[email protected]', '07015976349', 'No22 Miland str', 'Ikeja', 'Lagos', '860213', 'Nigeria', 2),
(017, 'Abraham', 'Dimas', '2000-12-12', 'Male', '[email protected]', '09048796852', 'No30 Sabon gari str', 'Jalingo', 'Taraba', '860013', 'Nigeria', 1),
(018, 'Juliana', 'Joseph', '2004-09-16', 'Female', '[email protected]', '08069857412', 'No70 Sabon gida str', 'Zing', 'Taraba', '670003', 'Nigeria', 2),
(019, 'Hadiza', 'Sani', '1998-05-19', 'Female', '[email protected]', '08011116595', 'No39 barrack str', 'jimeta', 'Adamawa', '560013', 'Nigeria', 1),
(020, 'Sharifa', 'Hassan', '2000-04-16', 'Female', '[email protected]', '08138200450', 'No66 Akata str', 'Wukari', 'Taraba', '440213', 'Nigeria', 3);
select * from students;

You might also like