Don't ask to ask, just ask | |
PerlMonks |
Re^2: DBIx::Class and "complex" joins (was Re^4: DB: what kind of relationship?)by 1nickt (Canon) |
on May 04, 2020 at 01:50 UTC ( [id://11116415]=note: print w/replies, xml ) | Need Help?? |
Thanks, Toby. Glad it was of interest. With regard to the language issue; of course you are right that I over-simplified. I was trying to come up with a schema that could show some relatively complex joins: I thought about the family, the CD collection and the farm, but they've all been done ;-) Language is a thorny problem. As you say, some artists might speak a primary language that can not be derived from their country, so Language should probably be a property of the Artist. And some artworks might indeed be "in" a language that is not the artist's primary language ... so the Language should also be an attribute of the Artwork ... but does a Painting have a Language? Probably it needs to be nullable, or maybe an attribute of only certain types of artwork in their respective tables. With regard to the primary key in the Painting, Play and Poem tables, and having an extra column named <entity_type>_id, as I mentioned I prefer to have separate names because it can make column aliasing simpler, and also because it allows for future expansion. What if I realize that most poets publish collections of poetry as an artwork? I will have to add a name column to the Poem table and backfill it. But other than that, all I have to do is drop one unique key: ... add a different multi-column unique key: ... rerun dbicdump, and my classes will be rebuilt with a one-to-many relationship between Artwork and Poems (with all custom code preserved). Then I could get the number of Poems in the collection, or the other Poems, with code like:
Won't be tweaking this demo any more for now though :-) Thanks,
The way forward always starts with a minimal test.
In Section
Seekers of Perl Wisdom
|
|