Final-Term Lab Examination Fall 2025
Program(s)/Classes: BSE-3A
Subject: Database Systems
Instructors Name: Mamuna Fatima
Date: 16 Dec,2025
Group Members:
Aryyan Ali (FA24-BSE-004)
M Saqib (FA24-BSE-043)
Haroon Ali (FA24-BSE-125)
M Nabeel (FA24-BSE-137)
Apply Queries to your DB project.
SELECT with ORDER BY:
Aggregate Functions:
GROUP BY with HAVING Clause:
Inner Join:
Left outer join and Right outer join:
Self Join:
SubQuery:
Create Update and Delete Query:
Create View:
Q No. 2: NoSQL Databases (Using MongoDB)
1. What is NoSQL?
NoSQL stands for Not Only SQL.
It is a type of non-relational database used to store large amounts of data
in a flexible way,
Data is not stored in tables
No fixed schema
Faster for large and unstructured data
Highly scalable
Examples
MongoDB
Cassandra
Redis
2. Difference between SQL and NoSQL Databases
Feature SQL NoSQL
Database Type Relational Non-relational
Data Storage Tables Documents / Key-Value
Schema Fixed Schema-less
Scalability Vertical Horizontal
Joins Supported Not commonly used
Examples MySQL, Oracle MongoDB, Firebase
3. What is a document in MongoDB?
A document in MongoDB is a single record stored in JSON-like format
(BSON).
Example
{
"student_id": 101,
"name": "Ali Khan",
"age": 21,
"department": "Computer Science",
"cgpa": 3.6
}
4. What is schema-less design?
Schema-less design means:
No fixed structure is required
Documents in the same collection can have different fields
Example
{ "name": "Ali", "age": 21 }
{ "name": "Ahmed", "age": 22, "cgpa": 3.8 }
Both documents are valid in the same collection
5. When should NoSQL be preferred over SQL?
NoSQL should be used when:
Data size is very large
High performance is required
Data structure changes frequently
Real-time applications are needed
Big Data or cloud-based systems are used
6. Create a database and two collections
Create Database
use universityDB
Create Collections
[Link]("students")
[Link]("courses")
7. Insert one document with at least 5 fields
[Link]({
student_id: 101,
name: "Ali Khan",
age: 21,
department: "Computer Science",
cgpa: 3.6
})
8. Write 5 MongoDB Queries
1. Display all students
[Link]()
2. Find students from Computer Science department
[Link]({ department: "Computer Science" })
3. Find students with CGPA greater than 3.0
[Link]({ cgpa: { $gt: 3.0 } })
4. Update CGPA of a student
[Link](
{ student_id: 101 },
{ $set: { cgpa: 3.8 } }
)
5. Delete a student record
[Link]({ student_id: 101 })
End.