Nonatomic Attributes in Classes

Nonatomic Attributes in Classes

Unluckily, even when a class properties are all attributes we may have some trouble converting the class to a relation. The reason is that attributes in ODL can have complicated types such as structures, sets, bags, or lists. On the other hand, a basic principle of the relational model is that a relation's attributes have an atomic type, such as numbers and strings. Thus, we must find some way of representing nonatomic attribute types as relations.

Record structures whose fields are themselves atomic are the easiest to handle. We simply expand the structure definition, making one attribute of the relation for each field of the structure. The only possible difficulty is that two structures could have fields of the same name, in which case we have to invent new attribute names to differentiate them in the relation.

Class with a structured attribute

Example :  In Figure (a) is a declaration for class Star, with only attributes as properties. The attribute name is atomic, but attribute address is a structure with two fields, street and city. Therefore, we can represent this class by a relation with three attributes. The first attribute, name, corresponds to the ODL attribute of the same name. The second and third attributes we shall call street and city they correspond to the two fields of the address structure and together represent an address. Therefore, the schema for our relation is

Street(name, street, city)

Figure (b) shows some usual tuples of this relation.

A relation representing stars



Tags