I've got an issue modelling a database to store some Java Objects (classical problem of mapping objects to a relational database). A example beeing far better than a long description, here's the stuff.
List of avaliable classes :
- Class A contains an array of doubles
- Class B contains an array of A
- Class C contains an array of B and an array of A (it can go on like that...)
All the objects implements the same parent (let's say StorableObject). There can be as many combinaisons as possible.
How can I store all theses values, and moreover, how can I create a model using some FK that deletes all its child when a parent object is deleted. I mean, since the childs can be stored in various tables, there's no way I can put a simple FK on the parent's field.
Thanks ;)
You've read too many OO books and not one RDB book. Model the data, as data, first. Ensure all your data requirements (as per your question) are satisfied. Then model your objects after the entities.
There are hundreds of identical questions on SO, by people who have arrived at the exact same obstacle. Different table and column names, but the same identical problem. Fowler brought all of you here.
To examine your data closely and provide a useful answer, we need to see your DDL or class diagram or whatever you have.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With