简体   繁体   中英

Theoretical: about php, mysql, comma separated values

I have a database with employees. the columns are first name, last name, department, internal number etc..

As for today it is a database only for one organization but in future i want to add to this database employees from other relative organizations.

What is the right way to do it:

  1. To add another field to the first table ?
  2. To create another table with 3 fields: id, organization_name, employees ( where in this filed i would put comma separated values of id from first table) ?

if the second answer will be chosen what will happened when an update query will be executed simultaneously from different accounts to the same organization. For example: i will be adding a user with id 55 to organization 'Police' and at the same time another administrator will be adding to the same organization a user with id 65.. In this case is there a possibility of error or data-loss ???

If someone had this kind of problem before, i really would like to read about it.. Thank You..

If the organization is only a number to group the users, then I would suggest to put them into the employees table. However if you have more information about the organization (eg name, address .. ) then make a new table for the organization and save the primary key of the corresponding organization in the employees-table.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM