I'll try and simplify as much as possible, however, if you need more information please let me know.
I'm using Rails 4
and PostgreSQL
edit:
- using PSQL 9.3
- the dataset won't change often and for this particular table will probably only have 15 columns
I have a design where there are "core" components
that have default attribute values like:
- material = wood
- color = blue
- price = $1.52
- dimensions = 3x2x5
These "core" components
and their default attribute values are managed by an admin who can make adjustments through an admin interface as needed.
A user can create a new component_group
and it will pre-populate with available components
. The components
in the new group all use the default attribute values of their "core" component
.
A user can then modify the attribute values of any of the components
that the group contains.
What I currently do is: duplicate each "core" component
to create a new unique record with the identical attribute values of the "core".
My concern is, that this app will potentially create a HUGE amount of records; many of those records may not have their default attribute values changed. While I don't know definitively, this seems like it's going to eventually be a performance problem (especially when you consider that in the real world scenario, components
will have their own relations which may need to be duplicated as well).
My initial thought was to implement some kind of system where a new component
record is only created if it's attribute values are changed, otherwise the component_group
referrers to the "core" component
.
So my questions are:
- Is my current approach even remotely correct?
- Are my performance concerns valid, or will it be insignificant to the DB?
- Would this type of functionality be better suited to a
NoSQL
DB likeCouchDB
? - Is there a specific name for this type of functionality? I've looked at
Class-Table Inheritance
/Multi-Table Inheritance
but I don't think that's what I'm looking for.