Ensuring Disjoint Subclasses in CQL

15 views
Skip to first unread message

Yuri de Wit

unread,
Mar 18, 2025, 7:59:28 PMMar 18
to Categorical Data
When designing data models, there is often a trade-off between a more generic (or denormalized) design, where multiple subclasses share a single relation, and a more structured approach that models subclasses using a base relation (the superclass) along with one or more subclass relations. For example, the Substrate and Fertilizer entities could be modeled as different types of a common RawMaterial entity. Another example is modeling Employee and Student entities as subclasses of a common Person entity—though, in theory, a student could also be an employee.

My question is: how can a schema be constrained to ensure that the different subclasses of RawMaterial are disjoint?

As I understand it, CQL supports embedded dependencies (EDs) as constraints, but EDs do not support negation—for example, enforcing forall p in Person, not(p in Employee ∧ p in Student). Is that correct?

Ryan Wisnesky

unread,
Mar 19, 2025, 12:07:37 AMMar 19
to categor...@googlegroups.com
Hi Yuri,

It is indeed the case that in so-called “regular logic”, there isn’t support for disjunction; if you allow disjunction, then the chase may not give a single answer.  How would you chase a database with a rule like Person(X) -> Old(X) or Young(X) and get a unique answer?  You really can’t.

Anyway, the usual “trick” is to rely on the custom that CQL and other chase engines will halt with an error if they detect contradictions / non-conservativity.  So although Person(X) -> Old(X) or Young(X) just doesn’t work, we could write a rule that says Old(X) and Young(X) -> 1=2, and then CQL would halt with a contradiction if it ever encountered a Person X such that Old(X) and Young(X).

As for disjoint sub-classes, the usual trick is to rely on the custom that CQL and other multi-sorted logics have disjoint sorts, and use a type coercion “function” in the schema:

youngToPerson : Young -> Person
oldToPerson : Old -> Person

Or equivalent encoding with regular logic.


--
You received this message because you are subscribed to the Google Groups "Categorical Data" group.
To unsubscribe from this group and stop receiving emails from it, send an email to categoricalda...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/categoricaldata/c418f421-0aa0-4875-9450-03b00fe61f06n%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages