Relation Schema
Relation Schema
Definition
A relation schema is the intensional (structural) description of a relation: its name, its attributes, and the domain of each attribute — e.g., Students(id: integer, name: varchar(50), department: varchar(10), gpa: decimal(3,1)). It is the "blueprint," analogous to a CREATE TABLE definition, and it contains no actual data.
Example
Relation Schema: Students(id, name, department, gpa)
This tells us nothing about which students currently exist — it only states that any valid relation on this schema must have exactly these 4 attributes, each drawing from its declared domain.
How this differs from Relation / Database Schema
- Relation Schema is the structure for ONE relation; a Relation is the actual data (a set of tuples) conforming to that structure at a given moment. The same schema can have infinitely many different valid relations (instances) over time as the data changes.
- A Database Schema is the collection of ALL relation schemas in the database (e.g., the Students schema + Courses schema + Enrollments schema, together with cross-relation constraints). A Relation Schema is one component piece of the larger Database Schema.
Edge Cases
- A schema can exist validly with zero relations having been populated yet — an empty instance is perfectly legal under a defined schema.
- Changing a relation schema (e.g.,
ALTER TABLE ADD COLUMN) produces a new version of the schema; all future instances follow the new schema. Schema changes are structural and infrequent — unlike relations, which change with every INSERT/UPDATE/DELETE. - A relation schema can also declare constraints (primary key, NOT NULL, CHECK) as part of its intensional definition — these are structural rules, not data.
Key Takeaways / Q&A
Q: If I add a new student row, does the relation schema change? A: No — only the relation (instance) changes; the schema (attributes/domains/constraints) is unaffected by ordinary data changes.
Q: What is the relationship between Relation Schema and Database Schema? A: A database schema is the union of all relation schemas (plus any inter-relation constraints, like foreign keys) that make up the database.