-1

I'm new to data modeling. Currently working at creating a personal contact manager but I need some help with modeling the table relationships for a given view.

The final view columns I'm shooting for are:

  • orgName (that a PERSONAL_CONTACT belongs to)
  • contFirstName
  • contLastName
  • phnNumber where phnType = "Primary"
  • socHandle where socType = "Primary"
  • emailAddress where emailType = "Primary"
  • addrAddress where addrType = "Primary"

The current ER diagram is: enter image description here

This table setup doesn't look correct to me.

Both ORGANIZATIONS and PERSONAL_CONTACTS can have their own EMAIL, PHONE, SOCIAL and PHYSICAL_ADDRESSES, but a PERSONAL_CONTACT can only exist in a single ORGANIZATION.

Is this the correct way to organize these tables or am I approaching the relationships incorrectly?

EDIT 1: Based on @Akina 's input enter image description here

EDIT 2: enter image description here

EDIT 3:

  • This is where I ended up with the table schema enter image description here
SeaDude
  • 111
  • 6

1 Answers1

1

Look at:

organization ( orgGUID PRIMARY KEY, 
               orgName, ... );

person ( personGUID PRIMARY KEY, orgGUID REFERENCES organization (orgGUID), personName, ... );

contact ( contactGUID PRIMARY KEY, contactValue, contactType ENUM ('address', 'phone', ...), additionalAttributes );

junction ( orgGUID REFERENCES organization (orgGUID), personGUID REFERENCES person (personGUID), contactGUID REFERENCES contact (contactGUID), additionalAttributes, CHECK (orgGUID IS NULL or personGUID IS NULL) );

Akina
  • 20,750
  • 2
  • 20
  • 22