![]() | |
#11
| |||
| |||
|
|
A foreign key constraint is an inclusion dependency and an inclusion dependency is a referential constraint, but there are referential constraints that are not inclusion dependencies and there are inclusion dependencies that are not foreign key constraints. For example, a constraint that states that if there is a row in one table there cannot be a corresponding row in a different table is neither an inclusion dependency nor a foreign key constraint but is still a referential constraint nonetheless. ... |
#12
| |||
| |||
|
|
... What we'd nowadays call "complex", "semistructured", "unstructured", "unconventional" or even "nasty" data was explicitly excluded by Codd from the very beginning. ... |
#13
| ||||
| ||||
|
|
Tempts me to use a new term (at least I'm guessing it's new) - exclusion dependency, even if there is nothing new about what it connotes. |
|
*Personally, given that any dbms is likely to have a number of practical limitations, I don't see why a dbms couldn't allow restricted use of negation so that a foreign 'reference'/exclusion dependency might be read as "A{attr} = A{attr} AND (NOT B{attr})", which is basically of the same form as any inclusion dependency or what I call a reference. |
|
*Also suspect that we have a number of qualified names for that basic form (of which 'primary key' was apparently the first) simply because using the terms in a dbms' language makes it easy for implementers to physically optimize. |
|
IMHO the implementation artifacts don't really contribute to, nor involve, any essential theory except for the usually ignored theory of optimization. |
#14
| |||||
| |||||
|
|
Thanks to everyone. I think I understand more clearly now the inherent asymmetry of foreign key constraints. But now then my question is what is the common name for the semantic constraint that "attribute RV1:X and RV2:Y are sematincally joinable"? Hmm. Usually we talk about constraints when they're syntactic, because that's what makes it possible to enforce them automatically, simply by manipulating the symbols in the database. So what you actually mean is, what syntactic construct is appropriate for enforcing the semantics you describe. I'd argue that that's what domains were invented for. |
|
Because simply having the same type is not enough for example both OrderID and CouponID might both have type GenericID and yet we may want to state that it doesn't make sense to join them. I see at least two ways to view this. The first would be that you just made a modelling error -- you assigned the same syntactic type to two things that are actually quite different. What you should have done is to assign them two different types/domains, which would then stop them from being joined. The second way would be to say that you've now implicitly created a union type (Order|Coupon), and its key, GenericID, has to be such that OrderID's and CouponID's never overlap. That way you can join willy nilly, but the results will be identical to the case where you've isolated the ID's into two separate types. Carried out in full this approach eventually leads to a generalization hierarchy converging towards a fully generic Object, and thus database wide object/unique identifiers. |
|
It is well known that this is rather a contentious and dangerous design choice. In fact we can already see the first signs of trouble in your minimal example: what on earth do Orders and Coupons have to do with each other? What precisely are you trying to express by creating the union type? In order for that generalization to make sense, at the very minimum you should be able to point to some hypothetical field that could be shared between the two types, i.e. data belonging uniquely to the union type. What would that be, precisely? |
|
If you have the means of keeping such ID's private -- this would necessitate making the ID's fully opaque from an outside user's point of view, which cannot be done in any DBMS I know of -- you might just be able to justify their existence as surrogates. But this is still stuff that requires tremendous discipline and insight into the entity integrity issues that need to be addressed in addition to the referential integrity between the surrogates. I wouldn't recommend going down this slippery slope unless you're *absolutely* sure you know what you're doing -- I haven't seen a single wider scale deployment which got this right and didn't suffer integrity issues in the long run. |
|
Likewise attribute names for joinable attributes may be different in different relations (ie needing rename). Yes. Ideally the attributes wouldn't carry just a name and a physical level type (e.g. string, integer) but also a semantic type/domain. That way the name would indicate the semantics, or role, of the attribute in this given relation, the domain would indicate what it can be joined with and where to look for the set of permissible values, and the syntacting type associated with the domain would tell how to actually store the data. |
#15
| |||
| |||
|
|
On Oct 22, 7:34 am, Sampo Syreeni <de... (AT) iki (DOT) fi> wrote: Thanks to everyone. I think I understand more clearly now the inherent asymmetry of foreign key constraints. But now then my question is what is the common name for the semantic constraint that "attribute RV1:X and RV2:Y are sematincally joinable"? Hmm. Usually we talk about constraints when they're syntactic, because that's what makes it possible to enforce them automatically, simply by manipulating the symbols in the database. So what you actually mean is, what syntactic construct is appropriate for enforcing the semantics you describe. I'd argue that that's what domains were invented for. I agree that it is possible to enforce such join semantics with domains but I'm not sure it is entirely appropriate. I say that because to the greatest extent the RM is orthogonal to domains. To quote CJ Date "Databases In Depth" Chapter 2 Summary: "It's a very common misconception that the relational model deals only with rather simple types: numbers, strings, perhaps dates and times, and not much else. In this chapter, I've tried to show that this is indeed a misconception. Rather, relations can have attributes of /any type whatsoever/ -- the relational model nowhere predicates what those types must be, and in fact they can be as complex as we like ... In other words, the question as to what types are supported is orthogonal to the question of support for the relational model itself. Or (less precisely but more catchily): /types are orthogonal to tables/." To put this another way, the RM should be just as complete and effective for a universe with a single domain as it is for a universe with a rich domain set (such as you propose to handle my GenericID join constraint example). And placing constraints on /relational expressions/ seems as fundamental to the RM as placing constraints on /relational values/. By pushing such expression constraints off to domains, we are admitting that the RM itself has no support for constraining relational expressions and I'm not prepared to admit that limitation. Especially since it does provide support for constraining the values of relational variables. I will also note that both Codd and Date proposed RM mechanisms to operate the other way around ie to allow designers to force cross-domain operations. Codd with "Domain Check Overrides" and date with the THE_ operators that provide type coercion. |
#16
| |||
| |||
|
|
Keith H Duggar wrote: On Oct 22, 7:34 am, Sampo Syreeni <de... (AT) iki (DOT) fi> wrote: Thanks to everyone. I think I understand more clearly now the inherent asymmetry of foreign key constraints. But now then my question is what is the common name for the semantic constraint that "attribute RV1:X and RV2:Y are sematincally joinable"? Hmm. Usually we talk about constraints when they're syntactic, because that's what makes it possible to enforce them automatically, simply by manipulating the symbols in the database. So what you actually mean is, what syntactic construct is appropriate for enforcing the semantics you describe. I'd argue that that's what domains were invented for. I agree that it is possible to enforce such join semantics with domains but I'm not sure it is entirely appropriate. I say that because to the greatest extent the RM is orthogonal to domains. To quote CJ Date "Databases In Depth" Chapter 2 Summary: "It's a very common misconception that the relational model deals only with rather simple types: numbers, strings, perhaps dates and times, and not much else. In this chapter, I've tried to show that this is indeed a misconception. Rather, relations can have attributes of /any type whatsoever/ -- the relational model nowhere predicates what those types must be, and in fact they can be as complex as we like ... In other words, the question as to what types are supported is orthogonal to the question of support for the relational model itself. Or (less precisely but more catchily): /types are orthogonal to tables/." To put this another way, the RM should be just as complete and effective for a universe with a single domain as it is for a universe with a rich domain set (such as you propose to handle my GenericID join constraint example). And placing constraints on /relational expressions/ seems as fundamental to the RM as placing constraints on /relational values/. By pushing such expression constraints off to domains, we are admitting that the RM itself has no support for constraining relational expressions and I'm not prepared to admit that limitation. Especially since it does provide support for constraining the values of relational variables. I will also note that both Codd and Date proposed RM mechanisms to operate the other way around ie to allow designers to force cross-domain operations. Codd with "Domain Check Overrides" and date with the THE_ operators that provide type coercion. Domains, however, define what is or is not joinable because natural join applies the equality comparison to attributes with like names, and domains define equality comparisons. |
#17
| |||
| |||
|
|
On Oct 24, 3:13 pm, Bob Badour <bbad... (AT) pei (DOT) sympatico.ca> wrote: Keith H Duggar wrote: On Oct 22, 7:34 am, Sampo Syreeni <de... (AT) iki (DOT) fi> wrote: Thanks to everyone. I think I understand more clearly now the inherent asymmetry of foreign key constraints. But now then my question is what is the common name for the semantic constraint that "attribute RV1:X and RV2:Y are sematincally joinable"? Hmm. Usually we talk about constraints when they're syntactic, because that's what makes it possible to enforce them automatically, simply by manipulating the symbols in the database. So what you actually mean is, what syntactic construct is appropriate for enforcing the semantics you describe. I'd argue that that's what domains were invented for. I agree that it is possible to enforce such join semantics with domains but I'm not sure it is entirely appropriate. I say that because to the greatest extent the RM is orthogonal to domains. To quote CJ Date "Databases In Depth" Chapter 2 Summary: "It's a very common misconception that the relational model deals only with rather simple types: numbers, strings, perhaps dates and times, and not much else. In this chapter, I've tried to show that this is indeed a misconception. Rather, relations can have attributes of /any type whatsoever/ -- the relational model nowhere predicates what those types must be, and in fact they can be as complex as we like ... In other words, the question as to what types are supported is orthogonal to the question of support for the relational model itself. Or (less precisely but more catchily): /types are orthogonal to tables/." To put this another way, the RM should be just as complete and effective for a universe with a single domain as it is for a universe with a rich domain set (such as you propose to handle my GenericID join constraint example). And placing constraints on /relational expressions/ seems as fundamental to the RM as placing constraints on /relational values/. By pushing such expression constraints off to domains, we are admitting that the RM itself has no support for constraining relational expressions and I'm not prepared to admit that limitation. Especially since it does provide support for constraining the values of relational variables. I will also note that both Codd and Date proposed RM mechanisms to operate the other way around ie to allow designers to force cross-domain operations. Codd with "Domain Check Overrides" and date with the THE_ operators that provide type coercion. Domains, however, define what is or is not joinable because natural join applies the equality comparison to attributes with like names, and domains define equality comparisons. Domains also define a set of permissible values for attributes. However, that doesn't stop RM from adding additional constraints to limit those values further. |
|
Why should relational operations be any different in this respect from relational variables? Ie why shouldn't the RM allow us to further constrain what domains permit for both values AND operations? |
#18
| |||
| |||
|
|
You asked about semantic joinability. Semantically, the join works if like-named attributes have an equality comparison defined and not if they don't. ... |
#19
| |||
| |||
|
|
paul c wrote: Bob Badour wrote: ... You asked about semantic joinability. Semantically, the join works if like-named attributes have an equality comparison defined and not if they don't. ... In RT, how could they not define equality? What reason would one have to define an equality comparison to compare employee ids with department ids or with names? Or charge with current or potential? Or age with price? |
#20
| |||
| |||
|
|
Bob Badour wrote: ... You asked about semantic joinability. Semantically, the join works if like-named attributes have an equality comparison defined and not if they don't. ... In RT, how could they not define equality? |
![]() |
| Thread Tools | |
| Display Modes | |
| |