C++/OOP Associations model and database -
edit: called association because in head should this, seems implement aggregation... can discussed...
contextwhat larn in when associations, should utilize pointers.
for example: have 2 objects: person , movie. 1 person can several film , 1 film can done by/with several person. have:
class person { public: person::person(); int id; vector<movie*> movies; }; class film { public: movie::movie(); int id; }; main() { person person; film *movie = new movie; person.movies.push_back(movie); // setter improve but... }
or (please right me if wrong =d)
where troubles appearnow have many persons , movies , want save somewhere: in database.
you person you movies associated in order build whole object. but how them?do reconstruct new pointer of film each person concerned associate ? lose association property allow objects linked live own life.
do load database in ram and... ok forget this
what way cleverly? proper way given documentations?
i'm interested in simplified/pseudo code examples, dissertation... thx lot !
your question broad, , there's number of approaches, how bind database tables (and represent foreign key connections).
it's not how represent/handle kind of domain model snippet, you're presenting in code sample here.
@martin fowler provided eaa pattern catalogue reasonably research, , apply appropriate patterns these kind of object <-> relational mapping
problems address.
c++ database oop model
No comments:
Post a Comment