Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

Clarification on DB design...

$
0
0
Hi Folks,

I'm writing an application and kind of wish I paid more attention at University on database design :) I think I've got it right, but the ERM diagram that MySQL Workbench has created from my table create script has confused me a bit.

This is an example of the problem I'm having:

I have a table called person, the person can have multiple names, e.g. first, last, middle etc. Within my application I'll control the display by a field called name_order. If you delete the person then all the names for that person will be deleted.

Here are the two tables:

CREATE TABLE data_name(
person_id INT UNSIGNED NOT NULL,
name VARCHAR(32),
name_order INT UNSIGNED,
PRIMARY KEY (person_id),
UNIQUE INDEX (name)
) ENGINE=InnoDB;

CREATE TABLE data_person(
person_id INT UNSIGNED NOT NULL AUTO_INCREMENT,
title_id INT UNSIGNED,
date_of_birth DATE,
PRIMARY KEY (person_id),
FOREIGN KEY (person_id) REFERENCES data_name(person_id) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB;

I was under the impression that this is a one to many relationship. However, the ERM thats been generated is displayed like this:

Code:

                    /
data_name ||---------- data_person
                    \

To me, this means that one name could belong to many persons.

Can someone clarify this for me please?

Thanks,

Andy

Viewing all articles
Browse latest Browse all 13329

Trending Articles