php - Elements with common and separate properties in a database -


i have database table post, user can submit many types of posts, , these types share properties, , have properties of own. e.x: both video , standard posts have description, video posts have video link/file property.

what did creating table post containing common properties, creationdate , description.

and created other tables, containing other properties, , number of post types grows, think have add more tables.

of course, problem design when want retrieve 1 post, have retrieve data posts table, use id , type retrieve data type table (ex : videos table). , when want retrieve data of different types in 1 page i'll have handle many tables.

which seems not practical since i'm working php/mysql in apache server.

is there other better idea can implement same result?

your design follows technique described in . there outline of technique in info tab.

you might want explore using way speed things up, , way use post-id fk without having have different fk type each post type. speeds joins.

the down side have add new table whenever discover new post type. then, if building object model have add new subclass @ same discovery.


Comments

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -