Bag Atational

I'm coining an awkward term as a thought experiment. All these HolyWars over "pure" relational versus the acceptance of "duplicate rows" (AKA "bags" in data-structure-speak) in existing RDBMS got me thinking about the implications of such. What practical benefits are we giving up by giving in to bags? (Note that this does not preclude the existence of unique keys as an option, an added "constraint".) Is "bag math" sufficiently messier or less powerful than map-math (AKA "pure relational")? Is WaterbedTheory at play? --Top

SQL is, of course, "bagatational".

One practical benefit we give up by "giving in" to bags is that certain query optimisations which are possible on true relations are impossible with bags. Query expression re-writes that may be used on relations will produce duplicate (or more duplicate) rows when applied to bags. Presumably, duplication has meaning in a bag-oriented system (otherwise we wouldn't need duplicates), so this is obviously unacceptable.

A second practical benefit we lose is the ability to detect and prevent double-entry errors. Presumably, if we want duplicate rows in a table, then duplication has meaning. In a system that allows duplicate rows, that meaning is hidden. The existence of a duplicate obviously means something (otherwise we wouldn't be allowing duplicates), but we choose not to indicate it. So, if we accidentally double-enter a row, how do we distinguish that erroneous extra row from a meaningful duplicate?

'''In the same way in which we distinguish errorneous extra row in a table that has autoincrement primary key. Hardly. Uniqueness doesn't help to prevent errors by itself. Also, what makes you think that duplication must mean something? Sometimes we just don't care about it at all. Perhaps we only want to know if a record exists or if it is before/after some other record. If YAGNI uniqueness, then don't do it. --Grey'''

[Conversely, if you aren't gonna need duplicate rows, why support them? -DavidMcLean?]

Continued at BagAtationalDiscussion


(Discussion moved from HowOtherQueryLanguagesAddressSqlFlaws)


See Also: DynamicRelational, RecordBasedDatabase, BagSetImpedanceMismatch, BagVersusSetControversyRoadmap


CategoryDatabase


AprilTen


EditText of this page (last edited October 2, 2014) or FindPage with title or text search