php - PHPMyAdmin How to do datatype set of relationships -


today decided little automate work in phpmyadmin, create many relationships, there 1 problem. example have 2 tables: foodraws , allergens. in foodraws table have columns name, tags, etc.. , allergens. created relationship between foodraws.allergens , allergens.id. now, when i'm editing or inserting foodraws, can directly select id allergens foodrws.allergens field. one? when have example selected allergen id 6 , want add id 7 replaces id 6. need create "6;7". create field datatype set ('1','2',...,'14'), working in same way, cannot select more 1 id field. have ideas how solve that?

tables:

create table if not exists `raws` (   `id` int(10) unsigned not null,   `nameczech` varchar(50) collate utf8_czech_ci not null,   `nameeng` varchar(50) collate utf8_czech_ci not null,   `tags` varchar(100) collate utf8_czech_ci not null,   `allergens` set('','1','2','3','4','5','6','7','8','9','10','11','12','13','14') collate utf8_czech_ci default null ) engine=myisam auto_increment=78 default charset=utf8 collate=utf8_czech_ci;  create table if not exists `allergens` (   `id` enum('1','2','3','4','5','6','7','8','9','10','11','12','13','14') collate utf8_czech_ci not null,   `nameczech` varchar(50) collate utf8_czech_ci not null,   `nameeng` varchar(50) collate utf8_czech_ci not null,   `detailczech` varchar(150) collate utf8_czech_ci not null,   `detaileng` varchar(150) collate utf8_czech_ci not null,   `img` varchar(15) collate utf8_czech_ci not null ) engine=myisam default charset=utf8 collate=utf8_czech_ci; 

and data:

insert `allergens` (`id`, `nameczech`, `nameeng`, `detailczech`, `detaileng`, `img`) values ('1', 'obiloviny obsahující lepek', 'cereals containing gluten', 'pšenice, žito, ječmen, oves, špalda, kamut nebo jejich hybridní odrůdy', 'wheat, rye, barley, oats, spelled, kamut or hybrids', 'cerreals'), ('2', 'korýši', 'crustaceans', 'a výrobky z nich', 'and products made them', 'crustaceans'), ('3', 'vejce', 'eggs', 'a výrobky z nich', 'and products made them', 'eggs'), ('4', 'ryby', 'fishs', 'a výrobky z nich', 'and products made them', 'fish'), ('5', 'arašídy', 'peanuts', 'a výrobky z nich', 'and products made them', 'peanuts'), ('6', 'sójové boby', 'soya beans', 's výjimkou zcela rafinovaného sójového oleje tuků', 'except refined soybean oil , fats', 'soya'), ('7', 'mléko', 'milk', 'a mléčné výrobky', 'and products made milk', 'milk'), ('8', 'suché skořápkové plody', 'dry nuts', 'mandle, lískové ořechy, vlašské ořechy, kešu ořechy, pekanové ořechy, para ořechy, pistácie, ořechy makadamie queensland', 'almonds, hazelnuts, walnuts, cashews, pecans, brazil nuts, pistachios, macadamia nuts , queensland', 'nuts'), ('9', 'celer', 'celery', 'a výrobky z celeru', 'and products made celery', 'celery'), ('10', 'hořčice', 'mustard', 'a výrobky z hořčice', 'and products made mustard', 'mustard'), ('11', 'sezamová semena', 'sesame seeds', 'a výrobky z nich', 'and products made them', 'sesame'), ('12', 'oxid siřičitý', 'sulphur dioxide', 'a siřičitany v koncentracích vyšších než 10mg/kg nebo 10mg/l', 'and sulphites @ concentrations greater 10mg/kg or 10mg/l', 'sulphurs'), ('13', 'vlčí bob', 'big-leaved lupine', 'a výrobky z vlčího bobu', 'and products made lupine', 'lupine'), ('14', 'měkkýši', 'molluscs', 'a výrobky z nich', 'and products made them', 'molluscs');  insert `raws` (`id`, `nameczech`, `nameeng`, `tags`, `allergens`) values (1, 'vepřová plec bez kosti', 'pork shoulder, boneless', '2', ''), (2, 'olej rostlinný', 'vegetable oil', '', ''), (3, 'cibule loupaná', 'peeled onion', '', ''), (4, 'paprika mletá', 'paprika powder', '', ''), . . . (29, 'majonéza', 'mayonnaise', '', ''), . . . 

in id 29 need have allergens 3,6 , 7. how that, if phpmyadmin allows me add one, although have datatype set?

this better modelled many-to-many relationship.

you need add link table contains columns (for example) allergen_id , raw_id. can have multiple records in table per entry in raws, , attach each record multiple records in allergens without using set datatype @


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -