sql - How to dynamically add multiple items corresponds to single key in MySQL? -


i'm new mysql. want create table user_id , company_name , time time add entries under company_name. example:

user_id   |   company_name mike           google                facebook steve          nokia tom            whatsapp                siemens 

and when want search person should list companies person work , when required can delete company name corresponds person.

what best design if want write in mysql?

make company_name null-able column , while deleting, set column null like

create table person (user_id int not null,   company_name varchar(10)); 

you can search table person user_id like

select * person user_id = 3; 

while want delete company person, update like

update person set company_name = null user_id = 3 , company_name = 'google'; 

(or)

delete person user_id = 3 , company_name = 'google'; 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -