Re: Composite attributes

From: Larry Coon <larry_at_assist.org>
Date: Mon, 18 Nov 2002 15:38:27 -0800
Message-ID: <3DD979F3.6AE3_at_assist.org>


Juan Pardillos wrote:

> I'd like to know if a composite attribute (e.g., a subject code like
> 'CS2323', where 'CS' denotes the department and so on) can be in a
> relation or whether this is prohibited by the definition of relation.
> In other words, does the definition of relation prohibit composite
> attributes or only multivalued attributes?.

Well, "composite" means something slightly different. If you have a relation R with attributes (a, b, c, d) and (a + b) together form the primary key, then that's a composite primary key. But a and b are separate and distinct attributes. You're not doing that -- you're concatenating them together into ONE attribute.

You should take a step back from where you are -- is concatenating them together a good idea in the first place? The answer is usually "no" if there's ever any reason to address the parts individually. Since it's much easier to concatenate them when they are separate than it is to parse them when they are concatenated, there's rarely a good reason to store them concatenated.

Here's one example -- you said that in 'CS2323,' 'CS' represents the department. How do you validate that each entry includes a valid department? If you have a DEPARTMENTS table with all the valid departments, and your subject code was broken up into department and number, then you could do it with a foreign key. But with it concatenated, there's really no good way to enforce the domain.

Larry Coon
University of California
larry_at_assist.org
and lmcoon_at_home.com Received on Tue Nov 19 2002 - 00:38:27 CET

Original text of this message