Databases Reference
In-Depth Information
┌─────┬─────────────┐
│ SNO │ PQ │
├═════┼─────────────┤
.. .........
│ │┌─────┬─────┐│
│ S2 ││ PNO │ QTY ││
│ │├═════┼─────┤│
│ ││ P1 │ 300 ││
│ ││ P2 │ 400 ││
│ │└─────┴─────┘│
│ │┌─────┬─────┐│
│ S3 ││ PNO │ QTY ││
│ │├═════┼─────┤│
│ ││ P2 │ 200 ││
│ │└─────┴─────┘│
.. .........
└─────┴─────────────┘
Fig. 4.1: A relation with a relation valued attribute
I'll have more to say about RVAs in just a moment, but first I need to get a couple of small points out of the
way. To start with, I need to define what it means for a relation to be normalized:
Definition: Relation r is normalized if and only if it's in 1NF.
In other words, normalized and first normal form mean exactly the same thing—all normalized relations are
in 1NF, all 1NF relations are normalized. The reason for this slightly strange state of affairs is that normalized was
the original (historical) term; the term 1NF wasn't introduced until people started talking about 2NF and higher
levels of normalization, when a term was needed to describe relations that weren't in one of those higher normal
forms. Of course, it's common nowadays for the term normalized to be used to mean some higher normal form
(often 3NF specifically); indeed, I've used it that way myself in earlier chapters, as you might have noticed. Strictly
speaking, however, that usage is sloppy and incorrect, and it's probably better avoided unless there's no chance of
confusion.
Turning to my second “small point”: Observe now that all of the discussions in this section so far (the
definitions in particular) have been framed in terms of relations, not relvars. But since every relation that can ever
be assigned to a relvar is in 1NF by definition, no harm is done if we extend the 1NF concept in the obvious way to
apply to relvars as well—and it's desirable to do so, because (as we'll see) all of the other normal forms are defined
to apply to relvars, not relations. In fact, it could be argued that the reason 1NF is defined in terms of relations and
not relvars has to do with the fact that it was, regrettably, many years before that distinction (i.e., the distinction
between relations and relvars) was explicitly drawn, anyway.
Back to RVAs. I've said, in effect, that relvars with RVAs are legal; but now I need to add that from a
design point of view, at least, such relvars are usually (not always) contraindicated. Now, this fact doesn't mean you
should avoid RVAs entirely (in particular, there's no problem with query results that include RVAs)—it just means
we don't usually want RVAs “designed into the database,” as it were. I don't want to get into a lot of detail on this
issue in this topic; let me just say that relvars with RVAs tend to look very much like the hierarchic structures found
in older, nonrelational systems like IMS, 3 and all of the old problems that used to arise with hierarchies therefore
raise their head once again. Here for reference is a list of some of those problems:
3 And, perhaps more to the point, newer ones like XML (see Exercise 4.12).
Search WWH ::




Custom Search