0

I think multiplicity has to do with what kind of foreign key relationship tables have.

But when I'm reading answers like this: "If your FK is nullable your multiplicity in principal entity must be 0..1 - default value has no role in this because you can assign null to FK. So all your dependent entities must be in 0..1 - * relation with your principal entity." ..it can get quite intimidating.

Can anyone walk me through some of the SQL jargon? What is a 0..1 - * relationship?

hubatish
  • 5,070
  • 6
  • 35
  • 47

1 Answers1

2

0...1 means it relates to 0 or 1 entity For example

you have two tables

FOO
FooId
BarID

BAR
BarId
Name

FOO can have 0 or 1 BARS

0...*

Means the entity can have 0 to many relationships.

For example

FOO
fooId

BAR
barID
FooId

now FOO can have 0 or many bars associated with it

and last but not least

*...*

Foo
FooID

BAR
barId

FooToBar
FooId
BarId

Now BAR can have many FOO's and FOO can have many BAR's

gh9
  • 10,169
  • 10
  • 63
  • 96
  • In your example, is the only difference between the 0..1 relationship which side the table is on? It seems like FOO and BAR are the same, except reversed. Should I describe the entire relationship as "0..1 : 0..*"? Or perhaps "0..1 - *" as the answer to [this question](http://stackoverflow.com/questions/9292738/entity-framework-4-0-error-113-multiplicity-is-not-valid-in-role?rq=1) did? – hubatish May 21 '14 at 21:01
  • 1
    The relationship description is based off of what object you are describing. So a 0-* relationship if you are Describing Table A to Table B will turn into 1-0 relationship if you are Describing Table B to Table A. – gh9 May 22 '14 at 13:26