12/17/2002 A Translation of the One-to-One Relationship for Introductory Relational Database Courses Jonathan P. Bernick Department of Computer Science Coastal Carolina University Conway, South Carolina 29528 e-mail: jbernick@coastal.edu I. Abstract The translation of the one-to-one relationship from the Entity/Relationship model to the relational model while preserving one-to-one correspondence between the members of the participating entity sets is a topic that has been neglected in introductory database textbooks. In this paper we provide a simple method, intended for students taking a first course in relational database design, that accomplishes this without introducing nulls or violating the relational model. II. Introduction The difficulties of representing the one-to-one relationship in a relational database have been discussed in detail in database literature ([1]). This difficulty is particularly apparent in the translation of the one-to-one relationship from the Entity/Relationship (E/R) model to the relational model. An examination of representative introductory database texts shows a variety of methods used to translate the one-to-one relationship, all of which potentially allow the one-to-one correspondence between the members of the participating entity sets to be violated for some or all cases and/or require the acceptability of nulls in foreign key attributes, thus violating the relational model (see [2], [3], [4], [5], [6], [8], [10]). Indeed, in some texts the use
of the one-to-one relationship is not discussed ([9]), a method to translate it is not provided ([7]), or its use is actively discouraged ([4]). In this paper we present a translation of the one-to-one relationship from the E/R model to the relational model that preserves one-to-one correspondence between the members of the participating entity sets for all cases and does not violate the relational model. Designed to be easily understood by students, this method can be used to supplement a text that does not include an adequate translation of the one-to-one relationship. III. Translating One-to-One Relationships Let us consider the case of two strong entity sets, A with primary key attributes A p, and B with primary key attributes B p, related by a one-to-one relationship C. There are three possible cases: No total participation by either entity set, total participation by one entity set only, and total participation by both entity sets. No total participation by either entity set: We create relations A' and B' with the attributes of A and B respectively. Additionally, we create a relation C', whose attributes are the union of A p and B p with any attributes of C. A p and B p are thus both foreign keys in C' referencing A' and B' respectively; furthermore, we declare both A p and B p as candidate keys of C', ensuring that the one-to-one correspondence is preserved. Either A p or B p may be chosen as the primary key of C' ([1]). Total participation by one entity set only: We may assume without loss of generality that B is the strong entity set with full participation. We thus create two relations: A', which has the attributes of A, and B', whose attributes are union of the attributes of B with A p. A p is thus a foreign key in B' referencing A'; if we also declare A p a candidate key of B', the one-to-one correspondence is preserved ([1]). Total participation by both entity sets: A single relation C' is created, whose attributes are the union of the attributes of A and B with any attributes of C. We declare both A p and B p as candidate keys of C', ensuring that the one-to-one correspondence is preserved.
IV. Examples No total participation by either entity set: The Fred Mbogo Insurance Corporation institutes a mentoring program, pairing management trainees with experienced managers, with participation optional for both trainees and managers. A possible E/R diagram would be and the resulting relations would be (, ) (, ) (,, ), where and are foreign keys in referencing and respectively, and is a candidate key of. Total participation by one entity set only: The Mbogo Corporation decides to make participation in the mentoring program mandatory for all trainees. The E/R diagram is now and the resulting relations would be (, )
(,,, ), where is both a candidate key of and a foreign key referencing. Total participation by both entity sets: The Mbogo Corporation decides to make participation in the mentoring program mandatory for all trainees AND managers. The E/R diagram is now and the single resulting relation (,,,, ), where is a candidate key of. V. Conclusions In this paper, we have presented a translation of the one-to-one relationship from the E/R model to the relational model that preserves one-to-one correspondence between the members of the participating entity sets for all cases, does not require nulls, and does not violate the relational model. Since this topic is largely neglected in relational database textbooks, this technique can serve as a supplement to such texts. While the results presented here are for a binary one-to-one relationship, they can easily be generalized for unary and n-ary relationships. VI. Acknowledgements My thanks to John W. Stamey for his helpful comments.
VII. References [1] Date, C. J., A Note on One-to-One Relationships, in Relational Database Writings 1985-1990, Addison- Wesley, 1990. [2] Date, C. J., An Introduction to Database Systems, Seventh Edition, Addison Wesley Longman, Inc., 2002. [3] Elmasri, R., and Navathe, S., Fundamentals of Database Systems, Third Edition, Addison-Wesley Publishing, 2000. [4] Harrington, J., Relational Database Design Clearly Explained, Morgan Kaufman, 1998. [5] Mannino, M., Database Application Development and Design, McGraw-Hill Higher Education, 2001. [6] Mata-Toledo, R., and Cushman, P., Schaum s Outline of Fundamentals of Relational Databases, The McGraw-Hill Companies, Inc., 2000. [7] McFadden, F., and Hoffer, J., Database Management, Third Edition, The Benjamin/Cummings Publishing Company, Inc., 1991. [8] O Neil, P., Database: Principles, Programming, Performance, Morgan Kaufman Publishers, Inc., 1994. [9] Post, G., Database Management Systems: Designing and Building Business Applications, McGraw-Hill Higher Education, 2002. [10] Silberschatz, A., Korth, H., and Sudarshan, S., Database System Concepts, Fourth Edition, McGraw-Hill Higher Education, 2002.