- 4 Core Terms (Q1): A Database is the organized collection of related data itself. A DBMS is the software (like MySQL or PostgreSQL) that creates, protects, and queries that data. A Database System = Database + DBMS + software/users around it. A Database Application is the user-facing program (like a school portal) that talks to the DBMS.
- Database vs. Traditional File Systems (Q2, Q6, Q7): In old file systems, each department kept its own separate files—causing data redundancy (saving the same student address 5 times) and data inconsistency (updating one file but forgetting the others). A DBMS keeps one shared, controlled source of truth with self-describing metadata, program-data independence, and multi-user concurrency.
- People in Databases (Q3, Q4, Q5, Q10): Actors on the scene directly use or design the database (DBA = security/backups/permissions; Designers = decide tables & relationships; End-users = clerks/managers; Analysts & Programmers = build apps). Workers behind the scene build and maintain the DBMS software itself (engine developers, tool vendors).
- When NOT to Use a DBMS (Q9): When the database is tiny and simple, requires strict real-time speed with no multi-user overhead, or when licensing/hardware setup costs outweigh the benefits.
For comparison questions (like Q2 or Q10), draw a clean 2-column table on paper. Give 1 real-life university example (e.g., Registry vs. Bursary keeping different addresses for the same student) to make redundancy and inconsistency crystal clear.
- Conceptual vs. Logical vs. Physical Models (Q1–Q2): Conceptual = high-level picture for humans (entities & relationships, no tech jargon). Logical / Representational = tables and columns (relational model). Physical = how bytes, indexes, and files sit on disk.
- Schema vs. State/Instance (Q3): The Schema is the blueprint/table structure (rarely changes). The State (Instance) is the actual rows currently inside the tables (changes every second as people insert/delete).
- Three-Schema Architecture & Data Independence (Q4–Q5):
- External Level: Customized views for different users (hides sensitive columns).
- Conceptual Level: Complete logical structure of the whole database.
- Internal Level: Physical storage paths and indexes on disk.
- DDL vs. DML (Q6): DDL (Data Definition Language) defines or changes the structure (
CREATE,ALTER,DROP). DML (Data Manipulation Language) reads or changes the rows (SELECT,INSERT,UPDATE,DELETE). - Two-Tier vs. Three-Tier (Q9–Q10): In Two-tier, the client app talks directly to the DB server. In Three-tier, a middle application/web server sits between the browser and the DB server for better security and scalability.
For Q4, draw three stacked boxes labeled External → Conceptual → Internal with arrows between them so your handwritten answer stands out immediately.
- Building Blocks (Q2–Q4): Entity Type = category (e.g.,
STUDENT); Entity Instance = one specific student. Attributes describe properties: Key (underlined, unique), Composite (can split, like Name → First + Last), Multivalued (double oval, like multiple phone numbers), Derived (dashed oval, like Age from DOB). - Relationships, Degree & Cardinality (Q5–Q8): Degree = how many entities participate (Unary = 1, Binary = 2, Ternary = 3). Cardinality = max links (
1:1,1:N,M:N). Participation = minimum links: Total (double line = must participate) vs. Partial (single line = optional). - Weak vs. Strong Entities (Q9–Q10): A Strong entity has its own full primary key. A Weak entity (double rectangle) has no standalone key—it relies on a Partial Key (dashed underline) plus an Identifying Relationship (double diamond) to its owner.
- List the nouns in the scenario as rectangles:
DEPARTMENT,LECTURER,STUDENT,COURSE. - Attach every attribute mentioned in the text as ovals, and underline the unique IDs (
DeptNo,StaffID,StudentID,CourseCode). - Turn every rule/verb into a diamond with cardinality:
- Department ↔ Lecturer (one department has many lecturers; each lecturer belongs to one department →
1:N). - Department ↔ Course (
1:N). - Student ↔ Course (students register for many courses; courses have many students →
M:N— putRegistrationDate,Semester,Gradeon the relationship diamond!).
- Department ↔ Lecturer (one department has many lecturers; each lecturer belongs to one department →
- Strong Entities: Each rectangle becomes a table; its key attribute becomes the Primary Key (PK). Composite attributes flatten into simple columns.
- 1:N Relationships: Never create a separate table for
1:N! Take the PK of the "1" side and place it inside the "N" side table as a Foreign Key (FK). - M:N Relationships: You must create a new junction/bridge table! Its columns are the PKs of both linked entities (together forming a Composite Primary Key and individual Foreign Keys) plus any relationship attributes (like
Semester,Grade). - Weak Entities & Multivalued Attributes: Weak entity gets the owner's PK + its own partial key as a composite PK. Multivalued attributes get their own separate table with (Owner PK + Attribute) as PK.
Write each relation cleanly in schema notation like TABLE_NAME(PK, Col2, Col3, FK*), clearly labeling which column is the Primary Key, which is a Foreign Key, and which table has a Composite Key (your REGISTRATION bridge table!).
- Integrity Constraints (Q4–Q5, Q8–Q9): Entity Integrity = Primary Key cannot be
NULL. Referential Integrity = every Foreign Key value must match an existing Primary Key (or beNULL), with actions likeON DELETE CASCADEorRESTRICT. - Key SQL Clauses (Q6):
SELECT(columns to show) •FROM(table) •WHERE(filter individual rows before grouping) •GROUP BY(bundle rows forCOUNT/AVG) •HAVING(filter groups afterGROUP BY) •ORDER BY(sort result).
- a & b (CREATE TABLE): Pick sensible types (
VARCHAR,INT), declarePRIMARY KEY, and onCOURSEaddFOREIGN KEY (DepartmentID) REFERENCES DEPARTMENT(DepartmentID). - c (INSERT): Match the exact column order of
STUDENTwhen writingVALUES (...)for three records. - d, e, h (SELECT): Use
WHERE Gender = 'Female'for (e), and filter byDepartmentIDonCOURSEfor (h). - f & g (UPDATE / DELETE): Always include
WHERE StudentID = '...'so you only modify or remove that one student, never the whole table!
The lecturer wants to see that you can take a messy real-world CSV file, spot bad data without hiding it, clean it responsibly in Python (pandas), visualize the findings, and explain what you did in a short reproducible report.
- Trap 1 — Duplicate Record: Look closely at the last row—
S03appears twice with identical scores. Decide how to deduplicate (keep first) and log it. - Trap 2 — Missing Values (
—): Four rows (S05Python,S06Java,S09Database,S12Attendance) have dashes. Leave them empty instudent_performance.csvso pandas loads them asNaN, then decide whether to impute (e.g., median/mean) or drop—and justify your choice! - Trap 3 — Out-of-Range Score: Look at
S11: Python score is 105 (valid exam scores are0–100). Flag it, decide whether to cap/set toNaN/correct, and explain why in your report.
- Use relative paths only (e.g.,
pd.read_csv("student_performance.csv"), neverC:/Users/...). - Include both original
student_performance.csvand your cleaned CSV file. - Include your
.ipynbnotebook or.pyscript. - Export clear PNG charts (course comparison, attendance vs. score scatter plot, etc.).
- Write a 1–2 page report with your Name, Reg. No., steps to reproduce, cleaning decisions, and findings.
- Zip all files and email to
zspaki@nwu.edu.ngon/before exam day.
- Mutable vs. Immutable (Sets 02–04, 07): Strings and Tuples cannot be changed in place; Lists, Sets, and Dictionaries can. Watch out for aliasing (
b = ashares the same list in memory) vs. shallow/deep copying. - Choosing the Right Collection (Sets 05–06): Use a
setto remove duplicates and test fast membership; use adictfor key-value lookups (e.g., student ID → scores). - Comprehensions (Set 08): One-line loops like
[x*x for x in nums if x > 0]replace multi-linefor+append()cleanly.
- Parameters (Sets 09–10): Never use a mutable default argument like
def f(items=[])—useNoneinstead.*argscollects extra positional arguments as a tuple;**kwargscollects keyword arguments as a dict. - LEGB Scope & Recursion (Set 11): Python looks up names in Local → Enclosing → Global → Built-in order. Every recursive function needs a base case to stop and a recursive step moving toward it.
- Generators (Set 12): Functions using
yieldproduce values one at a time lazily, saving RAM on large datasets.
- OOP Pillars (Sets 13–20): Encapsulation hides internal fields (with
@propertyvalidation); Inheritance lets a subclass reuse/override parent methods viasuper(); Polymorphism lets different objects share one interface; Composition ("has-a") is often cleaner than deep inheritance ("is-a"). - Exceptions (Sets 21–24): Use
try(risky code),except SpecificError(never bareexcept:),else(runs only if no error), andfinally(always cleans up files/resources).
- NumPy (Sets 25–26):
axis=0computes down columns (e.g., per subject);axis=1computes across rows (e.g., per student). Basic slices share memory (use.copy()when needed). Usenp.clip(..., 0, 100)to cap values at 100. - pandas (Sets 27–28):
Series= 1D column;DataFrame= 2D table.locselects by label (inclusive end);ilocselects by integer position (exclusive end). Useto_csv("out.csv", index=False)to export cleanly. - Matplotlib & Interpretation (Sets 29–30): Bar chart = categories; Histogram = distribution/bins; Line chart = trend over time; Scatter plot = relationship between two numeric variables. Remember: correlation does not prove causation!