A table stores records with fields; a primary key identifies each record. Related tables use foreign keys so the same fact is not copied inconsistently. A query selects, filters, sorts, groups, or combines records for a particular question.
SELECT course_code, title
FROM Courses
WHERE active = true
ORDER BY course_code;
Forms support controlled entry; reports present results for a purpose. Validation rules, required fields, suitable data types, and referential integrity prevent common errors. A database should store facts once where practical and derive reports through queries.
Exercises
Design tables for students, courses, and enrollments.
Write queries for active courses and a student's enrollments.
Identify a duplicated fact and normalize it.
Self-check
What is a primary key?
Why use a foreign key?
What does WHERE do?
Self-Check Quiz
1. What uniquely identifies a record?
AnswerA primary key uniquely identifies each record in a table.
2. What does a query produce?
AnswerA selected or transformed view of stored records that answers a defined question.
Homework
Model a small library database.
Create entry validation and three useful reports.
Explain one integrity constraint.
Sample answerUse Books, Members, and Loans with primary keys and foreign keys. A loan references existing book and member records, requires a date, and prevents impossible return dates. Reports can show overdue loans, available books, and a member's current loans.