Development Underway on Ubuntu!

I've added a new feature this weekend. It would have only taken me about a half hour, but I encountered some major problems on the way. In my ORM system which I call "Dumb", table aliases were previously generated a stupid way. If a table referenced another table, and the two tables were possibly at the long end of a list of joins, it would generate table aliases something like this:


which would be joined from a table with an alias something like this:


This seemed to have worked well for a while amazingly. However, when I tried to build my latest addition, I ran into problems because my User table was being referenced towards the tail end of two different branches in the so-called "join hierarchy". Through much trials and tribulations, I eventually ended up creating a class called "JoinHierarchy" so I could get consistent and unique table aliases. I created a thing called "NewsPicture" which basically links a News item (what you're reading) to a Picture. There's also a "NewsDownload" so I can list downloads as well. Here's what NewsPicture and its join hierarchy looks like:

NewsPicture [PictureId, NewsId, Sequence (for ordering)]
PictureId -> Picture -> PictureAlbum -> User -> Bio
NewsId -> News -> User -> Bio

So as you can see, User and Bio were being joined twice but under the same alias, so MySQL has a problem with that, as well as any database management system out there. Now, each object that can potentially be saved to the database has its own join hierarchy that you can just call up whenever you need a table alias or to get all the joined fields or join statements (including left joins if something could potentially allow null). Take a look at the images and downloads below!! I'll just throw in some random ones this time.

blog comments powered by Disqus