Query Practice & Concept Understanding
Submitted by
Farzeen Abbas
Roll NO (24014198-258)
Section: C
Course Title: Database System Lab
Course Code: SE-204
Submitted to
Mam Alveena Ehsan
Department of Software Engineering
What I Did:
Created a University database
Made 3 tables: Students, Courses, Enrollments
Added sample data
Practiced all types of SQL queries
Tables I Created:
Students Table
o StudentID (Primary Key)
o FirstName (Cannot be empty)
o LastName (Cannot be empty)
o Email (Must be unique)
o Department
Courses Table
o CourseID (Primary Key)
CourseTitle (Cannot be empty)
CreditHours
Enrollments Table
EnrollmentID (Primary Key)
StudentID (Links to Students table)
CourseID (Links to Courses table)
Grade
Queries I Practiced:
1. Basic SELECT Queries
SELECT * FROM Students;
Results of SELECT * FROM Students query
2. JOIN Queries
SELECT [Link], [Link], [Link], [Link]
FROM Students s
JOIN Enrollments e ON [Link] = [Link]
JOIN Courses c ON [Link] = [Link];
JOIN query showing students with their courses and grades
3. Data Modification
-- Run these together and screenshot
SELECT * FROM Students; -- Show before
INSERT INTO Students VALUES (4, 'New', 'Student', 'new@[Link]', 'Science');
SELECT * FROM Students; -- Show after
4. Testing Rules
Duplicate email error
INSERT INTO Students VALUES (5, 'Test', 'User', 'ali@[Link]',
'IT');
Error message when violating UNIQUE constraint
Conclusion
I successfully practiced all SQL concepts including:
- Data Definition Language (DDL) - CREATE TABLE
- Data Manipulation Language (DML) - INSERT, UPDATE, DELETE, SELECT
- Data Integrity constraints - PRIMARY KEY, FOREIGN KEY, UNIQUE, NOT NULL
- Complex queries using JOIN operations
This practical exercise demonstrates my understanding of database concepts and SQL query
execution.