Edexcel International Advanced Level Computer Science, point 4.1.2
Definition and function
A logical schema is the structure of a relational database, described independent of any particular software: its tables, their columns, the data types, the keys and the rules (constraints). It is the step after the ERM (4.1.1), and is what you turn into SQL (8.3) to create the database.
Logical and physical schema: the logical schema describes the tables, columns, data types, keys and constraints. The physical schema describes how the DBMS actually stores them on disk (files, indexes, storage order). The same logical design could be stored in different physical ways.
Why needed: it makes the design precise enough to build, checks that data will be valid, and keeps the data consistent.
a. Table (relation)
A table holds all the data about one entity, arranged in rows and columns. In theory it's called a relation. Example: a Member table in a library database.
b. Column (attribute)
A column holds one kind of fact about every record, and has a name and a data type. Example: Name.
c. Row (tuple)
A row holds one record: all the facts about one item (one member). Example: the row for member 1001.
| MemberID | Name | JoinDate | |
|---|---|---|---|
| 1001 | Amy Lee | amy.lee@mail.com | 2025-03-14 |
| 1002 | Raj Patel | raj.p@mail.com | 2025-11-02 |
- Column = attribute, row = tuple, table = relation.
- Each cell holds one value (no lists in a cell).
- The order of rows and columns doesn't matter.
d. Data types
Each column has a data type, which says what kind of value it holds, and limits what can be stored.
| Type | Holds | Example |
|---|---|---|
| Integer | Whole numbers | MemberID, Quantity |
| Real / float | Numbers with a fractional part | Price |
| Text / string (char, varchar) | Characters | Name |
| Boolean | True or false | IsPaid |
| Date / time | Dates and times | DateOfBirth |
Choosing the right type gives correct sorting and calculation, saves space, and gives basic validation.
e. Integrity constraints
A constraint is a rule that the data must obey, enforced by the database. They keep the data accurate and consistent.
Entity integrity
Every table must have a primary key, and no part of it may be empty (NULL) or repeated. This means each row can be identified.
Referential integrity
A foreign key value must match an existing primary key in the table it refers to (or be NULL if allowed). This means a link can never point to something that doesn't exist.
- You can't add a
Loanwith aBookIDof 999 if no book 999 exists. - You can't delete a member who still has loans, unless those loans are deleted or closed first (or the database cascades the change).
Domain integrity
Every value in a column must be within the allowed set of values (the domain): the correct type, range, format or list of choices.
DateOutis a date that can't be in the future.Emailcontains an @.Formatis one of Hardback, Paperback, Audio.Namecan't be empty (NOT NULL).
| Constraint | Protects against |
|---|---|
| Entity | Duplicate or unidentifiable rows |
| Referential | Broken links (orphan records) |
| Domain | Invalid values |
Writing a schema
Parenthetical form, with the primary key underlined, each foreign key followed by an arrow to its table, and the data type after each attribute:
Member (MemberID: integer, Name: text, Email: text, JoinDate: date)
Book (BookID: integer, Title: text, Format: text)
Loan (LoanID: integer, MemberID: integer → Member, BookID: integer → Book, DateOut: date, Returned: Boolean)
Loan has its own primary key, LoanID, because the same member can borrow the same book more than once (4.1.1); its two foreign keys aren't underlined.
Worked example
Task: a shop database has these two tables:
Product (ProductID, Name, Price)
OrderLine (OrderID, ProductID → Product, Quantity)
State a suitable data type and constraint for each column, and say which constraints stop an order line being added for a product that doesn't exist.
| Column | Type | Constraint |
|---|---|---|
ProductID (Product) |
Integer | Primary key (entity integrity) |
Name |
Text | Not empty |
Price |
Real | Domain: greater than 0 |
OrderID (OrderLine) |
Integer | Part of the composite primary key |
ProductID (OrderLine) |
Integer | Foreign key to Product (referential integrity), and part of the composite key |
Quantity |
Integer | Domain: 1 or more |
Referential integrity stops an order line being added for a product that doesn't exist, because ProductID in OrderLine must match a ProductID in Product.
Exam tip: use the exact terms table/relation, column/attribute, row/tuple. Name each constraint and what it prevents: entity integrity stops duplicate or missing keys, referential integrity stops broken links, domain integrity stops invalid values. You may need to find and correct errors in a schema, so check every table has a primary key and every foreign key points to one.
Check yourself
What is the difference between a row and a column?
A row (tuple) holds one record with all its facts. A column (attribute) holds one kind of fact for every record.
What does referential integrity ensure?
A foreign key value always matches an existing primary key in the table it refers to, so there are no broken links.
Give an example of domain integrity
A column DateOut that only accepts dates that aren't in the future (or Format restricted to Hardback, Paperback and Audio).
What does entity integrity require of a primary key?
It must be unique and never empty (not NULL) for every row.
Why choose the right data type for a column?
It makes sure values are stored and sorted correctly, saves space, and gives basic validation.