Skip to content
Exercises · Q3

Q.Differentiate between:

a) Database state and database schema
b) Primary key and foreign key
c) Degree and cardinality of a relation
West Bengal WbchseTextbookSubjective· 3mImportance★★★★★est
29% · 4/14 Questions
✓ Free question

Three classic pairs: schema is the blueprint while state is the data currently inside it; a primary key identifies tuples in its own relation while a foreign key points to another relation's primary key; degree counts columns while cardinality counts rows.

a) Database schema vs database state

BasisDatabase schemaDatabase state
What it isThe overall design: relation names, attributes, data types, constraints (keys, NOT NULL, CHECK)The collection of tuples actually stored in the relations at a particular moment
When it changesRarely — only when the design is altered (CREATE/ALTER TABLE)Continuously — every INSERT, UPDATE, DELETE produces a new state
Defined whenAt database design timeAt run time, as data flows in
AnalogyThe printed blank admission formThe pile of filled-in forms today

Example: STUDENT(RollNo INT PRIMARY KEY, Name VARCHAR(30), Class INT) is schema; the three rows currently stored in STUDENT are its state. The empty database (no data yet) is also a valid state — the empty state.

b) Primary key vs foreign key

BasisPrimary keyForeign key
PurposeUniquely identifies each tuple of its own relationLinks a tuple to a tuple of another (referenced) relation
UniquenessValues must be uniqueValues may repeat (many tuples can reference the same master tuple)
NULLNever NULL (entity integrity)May be NULL, if the relationship is optional
How manyExactly one per relation (possibly composite)A relation can have several foreign keys
Integrity rule enforcedEntity integrityReferential integrity

Example:

CREATE TABLE DEPARTMENT (DeptID INT PRIMARY KEY, DeptName VARCHAR(30));
CREATE TABLE EMPLOYEE  (EmpID  INT PRIMARY KEY, EName VARCHAR(30),
                        DeptID INT, FOREIGN KEY (DeptID) REFERENCES DEPARTMENT(DeptID));

EmpID identifies employees; DeptID in EMPLOYEE is the foreign key tying each employee to a department, and several employees may share DeptID = 10.

c) Degree vs cardinality of a relation

BasisDegreeCardinality
CountsNumber of attributes (columns)Number of tuples (rows)
Changes whenThe design changes (add/drop a column)Data changes (insert/delete rows)

Example — this relation:

RollNoNameClass
1Asha11
2Vikram11

has degree 3 (RollNo, Name, Class) and cardinality 2 (two tuples).

✓Final answer

a) Schema = the time-invariant design of the database (relations, attributes, types, constraints); state = the actual data stored at a given instant, changing with every insert/update/delete.

b) Primary key = the chosen attribute(s) that uniquely and non-NULL-y identify tuples in their own relation (entity integrity); foreign key = attribute(s) referencing another relation's primary key, possibly repeated or NULL (referential integrity).

c) Degree = number of attributes (columns); cardinality = number of tuples (rows). A relation of 3 columns and 2 rows has degree 3, cardinality 2.

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.