A Product can have lots of things said about it, I'll call them Properties. It can have a brief description. But that description can be in multiple languages. Likewise, it can have multiple Prices, some which are specific to Customers. Given the following data:
Product:
identifier: 123-ABC
Price:
value: $1.25
currency: USD
customer: Wal-Mart
Price:
value: $1.96
currency: USD
Description:
short: "A Widget"
language: EN
Description:
marketing: "Made from Space Age Polymers."
language: EN
Does it make sense to use STI here, and make a generic set of models:
Product h开发者_如何学JAVAas_many Properties
Property has_many Attributes
Price < Property
Description < Property
Package < Property
Is this way too broad of a generalization in the data model? Should I just stick with regular models and their associated tables?
No.
Seriously
No.
at least not in a SQL database.
If you want to use Cassandra or a NoSQL database, that's exactly how everything is stored.
Read my answer here and Read this
Think of a SQL Table with First Name, Last Name, and Birth date
Find all the LNAME = Page older than 30.
in one table it's
SELECT FNAME, LNAME, (SYSDATE - BDATE)/365 age FROM people WHERE LNAME = 'Page' and BDate < SYSDATE - 30*365
Now try it in an EAV
Post your answer.
精彩评论