Database question
    Dan Coutu 
    coutu at snowy-owl.com
       
    Tue Jan 24 13:35:01 EST 2006
    
    
  
Paul Lussier wrote:
>Dan,
>
>Is this what you meant:
>
>    class_types:
>
>    id   | integer | nextval
>    name | text    | not null
>
>    primary key: id
>
>    classes:
>
>    id   | integer | nextval
>    name | text    | not null
>    type | integer | not null
>
>    primary key: id
>    foreign key: type references class_types(id)
>
>    members:
>    id    | integer | not null
>    class | integer | not null
>    type  | integer | not null
>
>    primary key: name
>    foreign key: class references class(id)
>    foreign key: type references class_types(id)
>
>
>Then, based on the value of members.type, I could figure out which
>table to look up the member(id) in.  If it were of type 'class', then
>the id would map into that table, if of type 'machines', the id would
>map into the machines table, etc.///
>
>Thanks!
>  
>
Yes, this would work. Because the members table is provided a many 
(members) to one (class) relationship you can build data structures of 
arbitrary depth. Further, by using the class type indicator you can 
later expand the logic to include things that you have not yet 
considered in the same way that you're including the machines table here.
Dan
    
    
More information about the gnhlug-discuss
mailing list