Justtechjobs.com Find a programming school near you






Online Campus Both


php-db | 2001062

[PHP-DB] managing variant data From: Jesse Scott (jscott <email protected>)
Date: 06/25/01

Hi again, another conundrum.

What is the best way to deal with the following situation?

You have a group of common properties including a property that indicates a
second group of common properties. For example,
suppose you have this table:

Officers
------------
Name
Rank
Age
Height
Weight
Species

The 'Species' property may have the following values: Vulcan, Human,
Klingon, or Android.

If (Species==Vulcan) then you want to store these additional properties:
MindmeldCount and YearsOnVulcan
If (Species==Klingon) then you want to store these additional properties:
NumberofConcealedWeapons and RidgesOnForehead
If (Species==Android) then you want to store these additional properties:
PositronicBrain and MemoryJigas
If (Species==Human) then you want to store these additional properties:
AttendedStarfleetAcademy and BloodType

The problems I want to avoid are:
        1) placing all the properties for all species in the Officers table (as
this would include unnecessary properties for each row) and
        2) storing the properties in the Officers in four seperate tables
(Klingons, Humans, Androids, and Vulcans) redundantly.

Should additional tables be created: Vulcans, Klingons, Androids, Humans?
If so, how should these tables be joined to Officers?

In an object language I would solve a problem like this be creating a base
class with the Officers properties and then deriving new classes from this
base class using inheritance. How do I solve this problem in a database
setting?

Thanks in advance for your help,

Jesse

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-db-unsubscribe <email protected>
For additional commands, e-mail: php-db-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>