Tuesday, November 18, 2008

Relating Photos and MDOs

We had to make a decision regarding MDO objects and how they would be related to pictures. We decided that pictures will be hosted on the server separately from the database. Each photo has have a unique filename. The Photo table in the database has a unique id, a description, and the unique filename. This table is related to MDO in a relational table that has both ids.

The issue we had was with the initial population of the relational table. Previously, PublicArt objects had a value called 'c2kid' which was also used for the names of the images. They still have this 'c2kid', but the id is no longer used directly to access the images. Instead, we inserted new Photo rows into the Photo table for each PublicArt row, using the 'c2kid' as the name. We then inserted a relation into the relation table for each matching pair of 'c2kids' (PublicArt and Photo).

Using this method, we were able to populate the database while keeping a general format for the relation between the two classes instead of using an arbitrary string ID that is unique to PublicArt.

No comments: