in reply to They do respect set theory!
in thread (OT) Why SQL Sucks (with a little Perl to fix it)
It might have the same values for all attributes as some other row of the table, but it's still unique. Another way to think about it is that there is a hidden "unique ID" column in every table (you need only add such a column if the table has no primary key).
At first blush this seems like a compelling argument and I've struggled to find just the perfect example to explain the problem. I can't, so I'll go with an imperfect example. First, I want to paraphrase what you said so that if I have misunderstood you, you can correct me.
Consider the "supplier_parts" table:
+------------------+ | Supplier_Product | +------------------+ | SNO | PNO | +---------+--------+ | S1 | P1 | | S1 | P1 | | S1 | P2 | +------------------+
Your argument is that we can either infer the existence of a hidden "unique ID" or put an explicity primary key on the table to make the rows a set. You are right that this would turn the row into a set. However, it also violates 3NF. By substituting a clearer example, I can explain this better:
+-----------------+ | City | Country | +-------+---------+ | Paris | France | | Paris | France | | Paris | USA | +-----------------+
What you're suggesting is that I could do this:
+----------------------+ | ID | City | Country | +----+-------+---------+ | 01 | Paris | France | | 02 | Paris | France | | 03 | Paris | USA | +----------------------+
The bag of rows also constitute a set, but now, "Paris, France" is not dependent on the ID as required by 3NF. Assuming these truly represent the same city, are we referring to 01 or 02? Which one should other records point to? Merely adding a unique ID does appear to satisy the "set" constraint, but since it violates 3NF, we now have a denormalized database and cannot maintain data integrity.
Cheers on catching my bad SQL, though :)
Cheers,
Ovid
New address of my CGI Course.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: They do respect set theory! (and violate 3NF: yeah GIGO)
by demerphq (Chancellor) on Dec 12, 2005 at 08:20 UTC | |
by Ovid (Cardinal) on Dec 12, 2005 at 19:07 UTC | |
by demerphq (Chancellor) on Dec 12, 2005 at 21:32 UTC |