Conceptual, logical and physical database models
Overview
A conceptual model captures domain meaning and business rules without choosing a DBMS. A logical relational model specifies relations, attributes, keys and relationships. A physical model chooses actual engine types, constraints, indexes and storage decisions. The same training-center requirements can therefore have multiple valid physical implementations. Load er-training.sql in SQLite for the examples.
First example
SELECT name, type, pk FROM pragma_table_info('er_enrollment') ORDER BY cid;Observed SQLite result (rows in JSON):
[ [ "learner_id", "INTEGER", 1 ], [ "course_id", "INTEGER", 2 ], [ "status", "TEXT", 0 ]]How it works
Conceptual: learners enroll in courses and instructors teach courses. Logical: Learner(id, name), Course(id, title, instructor_id), Enrollment(learner_id, course_id, status), with key and reference rules. Physical: SQLite INTEGER PRIMARY KEY, TEXT NOT NULL, composite PRIMARY KEY and an index on er_enrollment(course_id). The first example inspects SQLite-specific column metadata using PRAGMA table_info; pk values 1 and 2 indicate the composite-key positions. The second inspects a named index via sqlite_schema, SQLite-specific metadata. PostgreSQL uses different catalog inspection and may use identity columns; these choices do not change the business meaning. An index is an access path, not a relationship. Do not infer speed from its existence: inspect workload and plans in the performance chapter.
Practical example
SELECT name, tbl_name FROM sqlite_schemaWHERE type='index' AND name='er_enrollment_course_idx';Observed SQLite result (rows in JSON):
[ [ "er_enrollment_course_idx", "er_enrollment" ]]Practice and mistakes
Practice: add the conceptual rule that a course can have a teaching assistant. Propose a logical optional assistant_id reference; decide whether it references an instructor or a separate entity according to domain requirements. Do not choose an index or storage format until the access patterns are known. Compare with the schema-definition and constraints chapters.