MySQL Forums
Forum List  »  Newbie

Re: Best data type to store lists?
Posted by: Phillip Ward
Date: July 02, 2021 06:58AM

Mostly likely, you need a joining table, allowing any number of Employees to attend any number of Events.

select * 
from Employees ; 

+----+--------+
| id | name   | 
+----+--------+
|  1 | Fred   |
|  2 | Barney |
+----+--------+

select * 
from Events ; 

+----+-------------------------------------+
| id | name                                | 
+----+-------------------------------------+
| 33 | Team Lunch                          |
| 44 | Bring your Brontosaurus to Work Day | 
+----+-------------------------------------+

select * 
from Event_Employees ; 

+----------+--------+
| event_id | emp_id | 
+----------+--------+
|       33 |      1 |
|       44 |      1 |
|       33 |      2 |
+----------+--------+

Is a very specific case, you might get away with having a single event_id in the employee record, but that would be of very limited use.

Regards, Phill W.

Options: ReplyQuote


Subject
Written By
Posted
Re: Best data type to store lists?
July 02, 2021 06:58AM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.