Originally posted by: SinNisTeR
Thanks for the insight 🙂
I agree with what you said about the role of the database. This is just a small fun project I wanted to learn how to do more functionally. This is by no means going to be used by anyone other than me. I think I need more information about both the mechanics and semantics as that would give me the overall knowledge I'd need.
Here is some more implementation information about where I'm currently at. First, I plan on using an XML file to store my mapping information. From there, I'll instantiate objects and store them in some kind of definitions file. In my configurations file I'll have a reference to my objects and XML file. Then I can use standard SQL queries (I'm using SQLite for now) to get the information I need from the database. I now need to know how I can take my XML mapping file and map the returned items from the query to the objects that the user has defined.
Let me give an example.. Say I have two tables, drivers and cars.
drivers
id - int
name - string
cars
id - int
make - string
model - string
driver_id - int
If I do "SELECT * FROM drivers, cars WHERE drivers.id = driver_id
then I get back something that looks like:
id string id make model driver_id
Now the id's I get back are ambiguous. Should I be re-writing the query to something more useful so I can distinguish?
Like: "SELECT drivers.id as driver-id, drivers.name as driver-name, .... etc ..."
When I get the result back, I now know the columns that relate to my objects in some way.
Also, since the query contains "FROM drivers, cars" am I safe to surmise that I'll be using instantiations of both of my objects (drivers, cars)?
These are questions I have about object relational mapping and how this is done. I don't need anything in depth (coalescing, cardinality, etc. this is a very simple project that I'm working on). I appreciate your input about the differences between the mechanics and semantics. 🙂