Diego Vin
Diego Vin

Reputation: 293

Best way to create these tables

I have the following situation.

We want an reputation table to evaluate Users And Companies.

This reputation table would store the reputation given by an Company to User and vice-versa.

It was suggested that we should create two reputation tables, one for the Users and another for the Companies, both with the same columns.

I dont think thats the best way but I cant find another solution.

Is there any other way we could do that?

thx

Upvotes: 0

Views: 112

Answers (2)

slashmais
slashmais

Reputation: 7155

You would have a table for the company containing a unique key for that Co. Same for the user.

I assume the relationship between Co and User is many-to-many.

You need one more table containing both keys, for Co and User, and two fields, one for Co-rep and one for User-rep. The Co-key and User-key combination would be unique entries for this table.

Upvotes: 0

lanzz
lanzz

Reputation: 43188

I don't think your approach is bad; another solution would be to have an abstract Entity table, with each User and Company having its own Entity record (and thus entity ID); then you only track reputation between two entities in a single Reputation table.

Another approach is to have a Reputation table with a user ID, a company ID, and a type (or direction, or whatever seems logical in your model) field which indicates whether it is reputation for the company given by the user, or the other way around. Seems less normalized though.

Upvotes: 1

Related Questions