On 6/3/2015 2:50 AM, Adrian Stern
wrote:
At the root of your description it appears to me that you are choosing essentially an EAV design pattern. Constraints and case specific validation become difficult (or impossible) to consistently enforce. I have personal experience in cleaning up a system that used this *exact* pattern (product -> product attribute). Different developers approached updating information in different ways. They also chose to store the attributes as text to avoid the text vs number issue. However, they failed to force any validation and any hint of attempting to prevent duplicates. That destroyed hope of supporting an underlying business need to search for specific values during data analysis. (think of how many different ways you can misspell "poughkeepsie" - but hey... it's "just a name") I inherited the results of poor development controls and poor control over the weakness of the design - e.g. validation... and the cleanup has been long, and painful. I think you should evaluate your unease with having to update the database on release (potentially many times) carefully for what it is and why you have it. [I'm not saying it is invalid - just know why you have it] Because no matter how well you design your system - databases evolve. Manage that. Anybody can muck up part of a project and cause garbage - but speaking from experience... this design pattern really encourages it. If you choose to use it - then you HAVE to control where and when inserts/updates are done and be very careful with specifying how validation is to be done to the entire development team (and potentially the users)... and then review the code (and/or data) regularly. wide tables/sparse fill on the columns ... I haven't tried to calculate the overhead on this... but disk space is generally considered to be cheap. [that doesn't mean your case wouldn't be criminally wasteful] Choosing 1 wide table or 30 sub-tables to deal with detail data. I don't know how that directly effects Postgres' performance.... if you choose 30 tables ... meh... at least you'll know exactly where your data is - and exactly what is allowed for each and every variant. Remember to enforce a consistent guessable naming convention. All that said - there are reasons to use this pattern to gain the power of the dynamically expandable configuration of allowed values. I just see the use cases where the gain (flexibility) is worth the pain (validation control) to be few and far between. just my $0.01 Roxanne
-- [At other schools] I think the most common fault in general is to teach students how to pass exams instead of teaching them the science. Donald Knuth |