Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Relationship vs Multiplicity

I've been looking everywhere but I couldn't find the difference between table relationships and multiplicities.

What's the main difference seeing that both of them can be one-many, many-one, and etc. The only difference I noticed so far is that multiplicities are depicted in 1..* format, or am I wrong?

If we have a table User and User can own multiple Blogs, what's the relationship here and what's the multiplicity?

like image 291
xtra Avatar asked Mar 13 '23 12:03

xtra


1 Answers

The two notations are related, but not the same.

The 1..*, 0..* etcetera represent the multiplicity of one end of a relationship. One-to-many is actually describing the multiplicities of both ends of a relationship; i.e "one-to-many" means 1..1 (or maybe 0..1) at one end and 1..* (or maybe 0..*) at the other end.

And as, you can see, multiplicity notation allows you to express optional versus mandatory relationships ... which "one-to-many" doesn't cover.


If we have a table User and User can own multiple Blogs, what's the relationship here and what's the multiplicity?

That would be described as one-to-many, but in UML you would express the relationship like this:

                BlogAuthorship

   -------- 1..1              0..* --------
   | User | <--------------------> | Blog |
   --------                        --------

which is also saying that:

  • a Blog must have a exactly one User as author, and
  • a User doesn't necessarily need to be an author of any Blog.
like image 173
Stephen C Avatar answered Mar 30 '23 04:03

Stephen C