[Previous] [Contents] [Next]


Step 3: One-to-one relationships


There is a one-to-one relationship between customer and users in our model. The process for conversion is as follows:

  1. Choose one of the two tables that participates in the relationship (this table has already been identified and written out as part of Steps 1 or 2). If the relationship involves total participation, choose the entity that totally participates.

  2. In the chosen table, include as an attribute (or attributes) the primary key of the other table.

  3. If the entities totally participate in each other and neither participates in another relationship, consider removing one of the tables and merging the attributes into a single table.

As users is the entity that totally participates in customer, the identifier cust_id from customer is added to the users table and defined as the primary key attribute:

CREATE TABLE users (
  cust_id int(4) DEFAULT '0' NOT NULL,
  user_name varchar(50) DEFAULT '' NOT NULL,
  password varchar(15) DEFAULT '' NOT NULL,
  PRIMARY KEY (user_name),
);

[Previous] [Contents] [Next]