There are two ways to do things:
1. If author1 ( say auth_1) creates a group (say gp_1) then it should be visible all the other authors as well. This is easy to implement but this way we do not ensure that every author must have his own preferences and thus auth_1 must have his own gp_1 and auth_2 must have his own gp_1
2. If author1 ( say auth_1) creates a group (say gp_1) then it should be visible to him only. If this is the case then auth_2 will also be able to create a group named gp_1 because for him user groups are different.
So to accommodate this the older suggested database(in proposal) could not work and had to be changed from :
1. If author1 ( say auth_1) creates a group (say gp_1) then it should be visible all the other authors as well. This is easy to implement but this way we do not ensure that every author must have his own preferences and thus auth_1 must have his own gp_1 and auth_2 must have his own gp_1
2. If author1 ( say auth_1) creates a group (say gp_1) then it should be visible to him only. If this is the case then auth_2 will also be able to create a group named gp_1 because for him user groups are different.
So to accommodate this the older suggested database(in proposal) could not work and had to be changed from :
1. group (group_id , group_name ,author_id)
2. group_users (group_id, user_id)
This will not work because here now if auth_1 submits the same form 2 times then 2 group_id's are generated and so we thought lets make group_name a primary key instead of group_id
1. group (group_name ,author_id)
2. group_users (group_id, user_id)
But now 2 authors cannot have the same group name for them as described above the group users list should be different for different authors.
So, finally to handle both the above issue, the following table is used
group_users(group_name, group_creator, user_id) PRIMARY KEY (`group_name`, `group_creator`, `user_id`)
This would handle both the above problems, different authors can have the same group name and single author cannot have two groups with the same name.
group_users(group_name, group_creator, user_id) PRIMARY KEY (`group_name`, `group_creator`, `user_id`)
This would handle both the above problems, different authors can have the same group name and single author cannot have two groups with the same name.
No comments:
Post a Comment