So Long MySQL

posted in Rarely Spoken
Published July 08, 2005
Advertisement
Thus far I've been using MySQL 4 for my CMS but it doesnt support sequences and I need them. Fortunately my host also supports Postgres SQL 7.4 which does have sequences. Yay!

I need sequences because I've made a change to my blog's database schema: an entry and a comment are now the same thing. Each has a unique ID and references the ID of a their parent. Top level entries are their own parents while comments may have a comment as a parent or an entry. I decided to combine the tables since they were almost the same table. The only difference was that the comment table originally had two extra fields: ParentID and ParentType. ParentType was an enum that would determin if ParentID referenced the entry table or the comment table. This sucked because I couldnt use ON DELETE CASCADE with that.

The reason I need a sequence is that in order to create a parent that references itself I need to get its ID before I insert it into the table which means I can use MySQL's ability to get the last value from AUTO_INCREMENT because it would be worthless.

Hopefully this wont be a hard change. I've abstracted the database enough that I should only have to change the class and then possibly a couple of my queries. The only ones I'm worried about are my paging queries because they use LIMIT. Of course I'll have to change my table to no longer use AUTO_INCREMENT as well.
Previous Entry A Change of Plans
0 likes 3 comments

Comments

paulecoyote
personally I prefer Postgresql too [grin]
July 08, 2005 02:54 AM
Colin Jeanne
I was looking into triggers in the Postgres docs and it looks like those might be useful in the future as well.

Yay!
July 08, 2005 03:38 PM
Lacutis
Why don't you just allow the field to be NULL?
If it's NULL, then its obviously a top level post. Thats how I handled it in the web based blog thing I wrote.
July 13, 2005 12:28 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement

Latest Entries

4E6 PyGame

1275 views

4E5

1023 views

Happy Yesterday!

978 views

Another Game

1172 views

Merry Christmas!

952 views

Hello There

957 views

Yay!

962 views
Advertisement