Re: [PHP-DB] managing variant data
Guten Tag Herr Scott, Montag, 25. Juni 2001, 11:21:42, schrieben sie: JS> Hi again, another conundrum. JS> What is the best way to deal with the following situation? JS> You have a group of common properties including a property that indicates a JS> second group of common properties. For example, JS> suppose you have this table: JS> Officers JS> JS> Name JS> Rank JS> Age JS> Height JS> Weight JS> Species JS> The 'Species' property may have the following values: Vulcan, Human, JS> Klingon, or Android. JS> If (Species==Vulcan) then you want to store these additional properties: JS> MindmeldCount and YearsOnVulcan JS> If (Species==Klingon) then you want to store these additional properties: JS> NumberofConcealedWeapons and RidgesOnForehead JS> If (Species==Android) then you want to store these additional properties: JS> PositronicBrain and MemoryJigas JS> If (Species==Human) then you want to store these additional properties: JS> AttendedStarfleetAcademy and BloodType JS> The problems I want to avoid are: JS> 1) placing all the properties for all species in the Officers table (as JS> this would include unnecessary properties for each row) and JS> 2) storing the properties in the Officers in four seperate tables JS> (Klingons, Humans, Androids, and Vulcans) redundantly. depends on what kind of DB you would like to use... on normal SQL-DBs you have to use something like Bill describes, on PostgreSQL you can use some feature like childs... says you make a officers-table with common values and then you make childs like klingon-officers, which "extends" officers. This means, that you all officers are automaticly stored in officers and the extra attributes are stored in the child-table. A third way is to use LDAP, there you can make an objectclass "officer" and a objectclass "klingon-officer" with the special attributes. Mit freundlichen GrĂ¼ssen Felix Meulenkamp --- KDT Klaus Daten- und Telekommunikationstechnik GmbH Ein Unternehmen der Ision Internet AG, Hamburg Robertstrasse 6* D-42107 Wuppertal, Germany tel +49 202 495-362mailto:[EMAIL PROTECTED] fax +49 202 495-399 http://www.kdt.de -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] managing variant data
I would create another table called "extras" that include all possible extra choices. This table has a SpeciesID field to assign it to a species. A third table called "details" could have OfficerID and ExtrasID and ExtrasValue fields. That way you could have as many or as few extras as you want. Filling out the data requires two forms. The first just gets the basic officer info. The second grabs the officerID and Species and displays only those "Extras" that pertain to that species. Submitting the info populates the "details" table. Queries link the officer & details tables on OfficerID. You can link the extras & details tables on the ExtrasID when you need. kind regards, bill hollett Jesse Scott wrote: > 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: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] managing variant data
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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]