bobier2
bobier2

Reputation: 147

MySQL : 1 relational table with 3 colmuns OR 3 relational tables with 2 columns?

I have 3 tables in a mySql (innoDb) database : Clubs, Members, and Years.

Which solution is better, and why ?

Solution 1 : 3 many-to-many tables (2 columns)

Solution 2 : 1 table for everything (3 columns)

More specific informations :

Upvotes: 0

Views: 55

Answers (2)

Ricardo Pinho
Ricardo Pinho

Reputation: 61

If there are not so many rows, it does not matter performance-wise.

The first solution is more efficient if the data will be queried in groups of 2 non-relational tables. However, queries for data in 3 non-relational tables will require a more complex query with INNER JOIN on all three relational tables.

The second solution retrieves more data, but makes queries more simple.

Upvotes: 2

Gabriel Osuobiem
Gabriel Osuobiem

Reputation: 30

I'll advise you not to use any of the solutions. According to the information you've provided, I don't see any reason why Years should be a table of its own since it doesn't have many rows.

This is my solution clubs_members (id club, id member, year)

Upvotes: 1

Related Questions