[Rails] How to model attribute and attribute-value dependencies

Rafa G.
Mon, 26 Jun 2006 23:00:49 -0000

With 80 attributes(or more!) I believe that your model entity-relation
isn''t very optimal.

Maybe I didn''t understand you correctly. This model, it''s very
simple,but it can help you and you''ll get some ideas:

              M:N                      M:N
Element -------------  Attribute -------------- Attribute_value

(Of course,it depend on the specifications)


Peter Ensch escribi?:
> I''m being sneaky and reposting this question; I got no anwsers
perhaps
> because I posted it over the w/end. I apologize for this but I''m
> completely stumped and need either an answer or some clue about how my
> approach is flawed. Thanks...
>
> I have a rails application which has a table ''cells''
which contains
> some 80 or so attribute fields (related to the electrical
> characteristics of macros that get hooked together and become micro-
> chips).
>
> I want to also store the legal values for many of those attribute
> fields in another database table. The problem is that
> 1) the sub-set of attributes that apply to each cell is dependent on
> the values of certain key cell attributes
> (eg. if the value of the type attribute is ''I/O'', then
certain
> attribute fields will not apply)
>
> and
>
> 2) the legal values of many of the attributes will vary depending on
> the value of other attributes
> (eg. if the value of the ''cell_type'' attribute is
''blah'' then the
> legal values for attribute ''foo'' are [abc, def, ghi],
otherwise they
> are [abc, ghi].
>
> I get the whole notion of single inheritance tables which I will need
> to use here; what I don''t get is how I can model these
dependencies in
> the database.
>
> Can anyone share a similar need they had and how they handled it.
>
> Thanks,
> Peter
>