-1

So, I have three tables Company(id), Person(id) and Review(comp_id, person_id, id). A person can leave multiple reviews for a company, so there is a one-to-many relationship.

The Review table has comp_id and person_id columns, which are foreign keys of Company.id and Person.id tables respectively.

So my question is whether it would be a good idea to

(a) Make the Review.id an auto increment primary key

or

(b) Make Review(comp_id, person_id, id) the primary key, and for each new record inserted start "id" value from zero.

An example of Review table with (a) would look like as below, where the id always increases:

1, 1, 1
1, 1, 2
1, 2, 3 
1, 3, 4
2, 2, 5
2, 2, 6

Whilst the same example with (b) would be as follows:

1, 1, 1
1, 1, 2
1, 2, 0 
1, 3, 0
2, 2, 0
2, 2, 1

Are there any advantages of (b) over (a)?

javasuns
  • 1,061
  • 2
  • 11
  • 22
  • 1
    Does this answer your question? [What's the best practice for primary keys in tables?](https://stackoverflow.com/questions/337503/whats-the-best-practice-for-primary-keys-in-tables) – He3lixxx Aug 28 '23 at 11:19

0 Answers0