MySQL Table inside Table or Alternative
A system I am making has Table Users, wherein each us开发者_Python百科er has his/her own userid.
Each user needs to belong to multiple groups.
Each group can have multiple users.
How would I accomplish this?
Three tables:
USER: - UserID - UserName
GROUP: - Group_ID - Group_Name - Group_Privelages
GROUP_USER: - Group_id - User_id
GROUP_USER would hold the relations of User to group - one user could be in many groups, or one, or none.
Use many-to-many association. Maybe this will help: http://www.tomjewett.com/dbdesign/dbdesign.php?page=manymany.php
精彩评论