Matt
Matt

Reputation: 7249

ERM model - ternary relationship with weak entity

I have a simple database design. It has entities: User Place Review. Basically a user can post a place (location of some place) and a user can post a review. Right now i have a ternary relationship between the 3 to be able to post a review about a place by a user.

It's like User ---- <post> ---- Review and Place ---- <post> ---- User

So, it's a 3 way.

First of all is the correct usage? As in, can i do that? I don't really care if it's not the best way, I just want to know if that is legit?

Second, i made Review a weak entity, but how can I make it so it takes the primary key of User and the primary key of Places? If i make it a weak entity will it automatically accept both of their primary ids?

Thanks!

Upvotes: 1

Views: 2654

Answers (2)

Damir Sudarevic
Damir Sudarevic

Reputation: 22187

enter image description here

Upvotes: 0

LeleDumbo
LeleDumbo

Reputation: 9340

First of all is the correct usage? As in, can i do that? I don't really care if it's not the best way, I just want to know if that is legit?

No to my eyes, as I see you connect place to itself in the 2nd relation. I assume it's a typo and you mean User----<post>----Place.

Second, i made Review a weak entity, but how can I make it so it takes the primary key of User and the primary key of Places? If i make it a weak entity will it automatically accept both of their primary ids?

The requirement is missing a couple of important things, such as:

  1. How many reviews can a user post about a place?
  2. Can more than one user post the same place?
  3. Can more than one user post review about the same place?

etc., so it's a bit difficult to give exact answer.

One example with the following assumptions:

  1. A user could post many places
  2. More than one user could post the same place
  3. A user could post only one review for a place

You could create this relation:

User(m)--<post>--(n)Place
           |
           |
         Review

If you explain a bit more maybe I could lead you to the expected solution.

Upvotes: 0

Related Questions