user2824512
user2824512

Reputation: 105

How to add 2 entries to 1 field in phpmyadmin without duplicating that row

Say that im building a DB of candy bars and one of the categories is "Flavor" say that a candy bar has more than 1 flavor, how do i represent that in phpmyadmin without creating a duplicate row?

Upvotes: 0

Views: 37

Answers (1)

Carlos Robles
Carlos Robles

Reputation: 10947

You need a more complex model:

  • candybar table, without flavour row.
  • flavours table, only an id, the name, and some other stuff if you want.
  • relationship table, containing rows with candybar_id and flavour_id

with this, a candy bar can have more than one flavour, and also a flavour can be associated with more than one candybar. This is a normal N-M relationship.

UPDATE:

If you are not familiar with this kind of issues, i recommend that you read some tutorials on how to model relational databases.

Upvotes: 1

Related Questions