You are here: Re: Database design for multiple types of products « PHP Programming Language « IT news, forums, messages
Re: Database design for multiple types of products

Posted by Rik on 06/05/07 07:02

On Tue, 05 Jun 2007 06:56:07 +0200, MadDiver <paixaop@gmail.com> wrote:

> Guys,
>
> I need to create an application that handles several product types/
> categories. Each product type can have totally different fields to
> describe it. For instance a car would have Year, Make, Model, and
> Miles, whereas a house would have Year, Address, SQ Feet, Amenities,
> etc.
> These are just examples but you get my drift.
>
> the application needs a form to input, show and search the data for
> each of the product types.
>
> I cannot hard-code each product type and its associated fields in the
> database, since one of the requirements is that an administrative user
> can create any product type he/she needs. The application then has to
> generate the forms for data input, show, and search on the main site.
>
> What are your suggestions as how to best address these requirements?
> What would be the best DB schema?

Giving less savvy users control over database schemes is somewhat tricky...

If they are totally independant, I'd say you've got your work cut out for
you.

Not a terribly good implementation, but one that would be somewhat
maintainable:

- Define some types of properties (Date, Number, Longtext, varchar etc.)
- Define some names templates for types (Car as varchar modelname, number
miles, date buildyear etc.)
- Have one major table having at least an ID (and every other field all
products will have in common.
- Have a properties table with property-id, product-id and the
property-value.
- Build forms & interfaces using that.

It gives you major flexibility, but it would mean the data of of your
'products' is scattered over several tables/rows. Not an ideal solution by
far, and I wouldn't even try it without cascading updates & deletes.

--
Rik Wasmus

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация