Forum Moderators: open

Message Too Old, No Replies

mysql - which option is best solution?

         

proper_bo

1:34 pm on May 2, 2006 (gmt 0)

10+ Year Member



I want to associate users with widgets.
I came up with two option (although you may be able to think of a third and better one).

1) a cell on each users row called widgets where the widget number and the level of the widget control the user has is listed like 23:1,45:3,22:2
mysql pulls the cell and php splits it into arrays of widget number and control level.
When a new widget is added or an old one removed the string is changed by php and then updated

2) a table called widgetrights which contains four columns:

widgetrights_id ¦ widget_id ¦ user_id ¦ level

widget_id matches to the id of the widgets in the widgets table
user_id matches to the id of the users in the user table
level is an integer between 1 and 3 stating the level of the control the user has.
When a new widget is added a new line is added to the table
When an old widget is removed a line is deleted

So I know that option 1 is faster for accessing the users widgets but I then need to process it and possibly call again to get the widget information
With option 2 it is slower but I could pull all the users widget rights and the widget information in one call.

What advice would you give on these options?
Are there any alternatives I have not considered?
Are there any problems when a user has 100 widgets?
Are there any problems when there are 1000's of users?

Thank you