Knowledge Representation (KR): Formalization of information with explicit rules, relationships, and constraints enabling computational reasoning and inference.
Key distinction: Not just storing facts, but encoding the logic to derive new facts automatically.
Example: "Mary is 30" + "All persons over 18 are adults" → infer "Mary is an adult"
Knowledge Engineering in Practice
Automated Inference: Derive new facts without explicit programming.
Semantic Search: Find information by meaning, not just keywords.
Data Validation: Enforce complex business rules beyond structural checks.
Decision Support: Provide explicit reasoning steps for decisions.
System Integration: Shared conceptual structures or formal mappings across disparate systems.
Explainable AI: Auditable reasoning chains for trust and compliance.
Where Mainstream SQL Practice Fits Awkwardly
Composability: Building reusable rule components and layered knowledge structures is cumbersome.
Procedural vs. Declarative: Complex rules often require stored procedures or triggers, scattering logic.
Integrity Constraints vs. Business Rules: Complex domain rules don't fit simple CHECK constraints.
Burdensome DDL: Schema changes in large RDBMS can slow agile knowledge evolution.
Schema-on-write rigidity: Must define structure before data, clashing with exploratory knowledge discovery.
NULL semantics: Missing-information handling can complicate formal reasoning and is not the same as explicit incomplete-knowledge semantics in KR formalisms.
The Three-Layer Problem
Conceptual Model: Domain meaning and business rules, technology-independent.
Logical Model: Maps to a data model (relational, graph, object), abstracts from storage.
Physical Model: Actual storage, indexing, performance optimizations.
The Problem: Traditional SQL practice often blends these layers. Choosing VARCHAR size (physical) can affect how "name" (conceptual) is treated. KE benefits from cleaner separation and looser mappings.
CWA vs. OWA: A Fundamental Divide
Closed World Assumption (CWA): Mainstream SQL usage usually works as if absent facts are false for practical query purposes.
Open World Assumption (OWA): Common in KR formalisms such as OWL. If a fact isn't known, it is not thereby false.
Impact: The issue is not merely whether a system has an "unknown" state. The issue is what absence means semantically, and whether the formalism treats missing facts as false or as still open.
SQL ≠ The Relational Model
Relational Model (Codd, Date, Darwen): Formal logical framework with rich declarative integrity constraints.
SQL implementations: Deviate from the formal model in ways that impact KR.
Key insight: Criticisms of SQL don't necessarily apply to the formal Relational Model itself.
The formal RM supports knowledge representation through declarative constraints. A "relvar" is a predicate stating truth about the world.
Date & Darwen: SQL's Deviations from RM
NULL values: Three-valued query semantics complicate reasoning and make SQL less clean than the formal model.
Lack of true assertions: Weak support for complex, cross-table integrity constraints. RM allows arbitrary assertions.
Duplicate rows/tuple ordering: RM uses mathematical sets (no duplicates, no order). SQL allows both, undermining logical purity.
Imperfect type system: Less sophisticated than needed for rich conceptual types and hierarchies.
The Composability Challenge
Date & Darwen: SQL lacks true closure—SELECT doesn't always produce relational results (duplicates, NULLs).
LINQ/Rx perspective: Impedance mismatch between SQL strings and host language type systems hinders modular composition.
Result: Building layered knowledge structures from reusable rule components is harder than in Datalog or relational calculus.
When SQL's declarative features fall short, developers resort to procedural code, scattering logical definitions.
Use SQL Where It Shines
Transactional integrity, joins, indexing, and execution plans.
Mature governance, operations, and performance tooling.
Strong substrate for views, materializations, and access control.
Data storage and retrieval of foundational facts.
Strategy: Use SQL for storage and execution where it fits, without forcing conceptual modeling and inference to collapse into the same layer.
SQL is Evolving (Stonebraker: "What Goes Around Comes Around")