Neko
Neko

Reputation: 3740

How represent multiple similar foreign keys in ERD database diagram?

I'm making an ERD of my database, and am stuck with a little dilemma.

Consider the tables foo and bar. foo has three columns that are foreign keys, referencing to bar's primary key. My question is: in the ERD do I represent this with just one line between those two tables, or do I use three lines?

Upvotes: 12

Views: 11870

Answers (3)

Utshaw
Utshaw

Reputation: 4276

Extending the accepted answer I am giving an example showing when multiple "lines" (relationship) are necessary for same attribute .
Suppose, there is an e-commerce site . customers can register there & they can send gifts to other registered customers. So, there are two relations between customer and gift entity.

enter image description here

First relation: customer gives gift
Second relation: customer receives gift
That's why we need two lines here.You need to consider all the relations & according to that you need to draw lines. As you have three relations you need to draw three lines.

Upvotes: 8

Branko Dimitrijevic
Branko Dimitrijevic

Reputation: 52137

Three lines, like this:

enter image description here

Upvotes: 8

Mosty Mostacho
Mosty Mostacho

Reputation: 43494

Use three lines. It is used one line per relationship.

PS: It is perfectly ok to have many columns reference the same column in another table. For example you can have a Person table and a Sports table and in the Person table you can have 3 columns such as FavouriteIndividualSport, FavouriteTeamSport, FavouriteExtremeSport

Upvotes: 3

Related Questions