mardi 2 décembre 2014

How to Implement Different Object Types as Similar Tables?


I have a database I am attempting to design. I am trying to determine the best approach to declare similar, but different types of objects, each with their own sets of properties (perhaps some properties identical between objects).


Let's say, for example, I am building a mall web app. I want to set up a facility for shop owners to register their stores, type of store and some specific information for that store. The problem I am faced with is the best approach to model different shop types and how to incorporate a model for data storage based on the type of shop.


To further extend the example with some concrete data (let's just pretend this information is all necessary for storage), what would be the best approach to model something like this:



Thai Fooooood
Shop Type: FoodShop
Most Popular Item: Pad Thai
Visitors Last Week: 368


Anti-Static Wristband Repair
Shop Type: RepairShop
Current Computer Repairs: 26
Repair Length Estimate (in business hours): 4
Visitors Last Week: 182


Macroputers
Shop Type: RetailShop
Next Promotion Date: January 2, 2015
Current Week Sales Estimates: 122418
Visitors Last Week: 411

Assuming many other instances of these shop types exist, with each type storing the same data. Does it make more sense to set up a table for each shop type, to use a single table to represent all shop types (using generic data), or is there a better approach?





Aucun commentaire:

Enregistrer un commentaire