What does it mean to write an algebraic relational expression for a referential integrity constraint in a database design?
-
For a start: What does an integrity constraint say & what are its leaf/terminal expresions & what does a relational algebra expression return & what are its leaf/terminal expressions? How are you going to use a table to state yes or no? PS [What is the equivalent, in Relational Algebra, of a SQL Table Relationship?](https://stackoverflow.com/q/48905581/3404097) – philipxy Nov 05 '21 at 22:01
-
What do you mean, "what does it mean"? Are you trying to ask how to do something? Or have you been given an example that is allegedly doing something & you don't understand it? Or have you been told to do something but don't understand what you were told or how to accomplish it? Or what? – philipxy Nov 05 '21 at 23:09
-
[expressing constraints in relational algebra](https://stackoverflow.com/q/28457182/3404097) – philipxy Nov 06 '21 at 02:37
1 Answers
Short answer: it can't be expressed, in general.
But perhaps you have in mind a less-general situation?
Longer answer: There's many variants of relational algebra. Maybe some are designed to express constraints; but the more common ones (especially Codd 1972) aren't.
You'd need a construct to return a Boolean (yes/no this database content conforms to the constraint(s)). Whereas most algebras are aimed at returning relation values.
Or you'd need a convention that (say) an empty result means 'valid' -- presuming an entirely empty database is valid; but some constraints are such that an entirely empty database is not valid; then you'd have to concoct a non-empty result, which would make your query 'domain dependent', which Codd took pains to avoid.

- 2,623
- 1
- 13
- 20
-
It's not clear what the stuff after the dash is trying to say. But given some things it is saying & maybe trying to say, it's not clear why it is there. The constraints on the database do not prevent constraints being expressed via an empty-or-not query. You don't need to "concoct a non-empty result" after you concoct a constraint's corresponding query; whenever a constraint fails the query will "concoct a non-empty result" per the invalid state it was given. (Granted the constraint & query languages have to have appropriately similar expressive power.) – philipxy Nov 06 '21 at 00:44