php - how can create categories with different options of it in mysql tables -
i want design database mysql categories options categories example : script classified .. when want add ads in "cars category" must add options car . when add ads in "apartments sale category" must add options apartment
or @ image dubizzle site classified
when want add car in "cars category" show options http://i.stack.imgur.com/gkgl8.png
and when want add ads in "apartments sale category" show options http://i.stack.imgur.com/dtnzi.png
how can design database such ??
categories , sub-categories different options categories
create table category ( id int auto_increment primary key, catname varchar(100) not null ); create table catoption ( -- no attempt share option across multiple categories id int auto_increment primary key, catid int not null, descr varchar(100) not null, listingorder int not null -- order listed on screen -- include fk category ); create table listing ( id int auto_increment primary key, catid int not null, title varchar(100) not null, verbeage text, price decimal(12,0) not null -- include fk category ); create table listoptions ( -- table houses particular listing options (answers if will) -- programmer chooses whether or not save 'blanks' id int auto_increment primary key, listingid int not null, optionid int not null, answer varchar(100) not null -- choose datatype -- include fk listing -- include fk catoption );
the foreign key constraint used prevent actions destroy links between tables.
the foreign key constraint prevents invalid data being inserted foreign key column, because has 1 of values contained in table points to.
Comments
Post a Comment