I was wondering if it's possible to do the following mapping: Take a class/table "Person" and a class/table "Asset" (3M share, Coca-Cola shares, Treasure bonds, Central Park Apartment, etc). And each "Asset" have an "AssetCategory" (stocks, buildings, bonds, etc). So, "3M" shares is of type "Stocks".
Take this as a Many-to-Many, once a person can invest in several assets. To map this we have an Person_Assets table. No problem for me here to map this as a M2M relationship inside a property named "allAssets".
But I was thinking if it's possible to add a propery named "cars", in the "Person", that maps all records in "person_assets" table, with type_id = X. And I also would have a property named "realEstates" that maps all records in "person_assets" table, with the type_id = Y.
In fact, "allAssets", "cars" and "realEstates" properties should map the same table, but "cars" and "realEstates" would be a subset of "allAssets". I think this would make my "API" a little bit simpler, once "cars" and "realEstates" are more often refered and I don't want to pass thru all assets only to check the type of each one...
Is it possible? What should I google/read to do this? Is it correct/recommended?
Thank you all.
|