nested sets (again) with group_concat()
If you haven't used them before, sub-queries are a very handy addition to your developer's tool kit. Traditionally, they are used to grab parts of data where the grouping in the main SQL query makes it difficult, or for getting similar result sets to outer joins. Going back to our nested set model, if you look at the examples for the adjacency set you can see that when they are getting the path to a node, the result set is one row containing several fields.
So, what do we want to do? We could do it programatically with a loop, and use two queries. I am always incredibly weary about placing queries in loops and I decided against this. All we really need to do is concatenate all the node names together into a string. Makes sense? So as we traverse the path, PORTABLE ELECTRONICS is appended to ELECTRONICS, and then MP3 PLAYERS is appended to the previous string, and finally FLASH is appended to this string.
Unfortunately, this method doesn't work either. Your 'node' and 'parent' elements will concatenate together, but again they will overwrite the previous concatenation. The only way around this is to use an aggregate function that is present in MySQL 4.1 called GROUP_CONCAT(). This will concatenate a field together based upon a GROUP BY clause. If we run the query:
So there you have it. GROUP_CONCAT()… I feel stupid that I never knew about it before. I use it every now and then in queries like this to produce a CSV from a dataset and use WHERE IN() or just return the string and 'explode' the list with PHP. Hopefully my little adventure with the nested set model and this MySQL string function proved useful to you. If you have any further ideas for making the query more efficient, or you can rewrite this without a sub-query, please: leave a comment!
rpg2knet development: can it be too complex?
Looking through what is complete at the moment (and I'd say we're definitely closing on half-way done), there is a tremendous amount of interactivity. These days, with the advent of the social web and the advances in user experience and interactivity, I'd say this isn't necessarily a bad thing. Conversely, the forum element has been dubbed 4um4-lite, as layers of complexity have been removed. The use of the forums is a much more tied in experience with the rest of the site. Previously, the forum had upwards of 85% of the traffic whilst the rest of the site languished behind. Now, there will be more of a reason to visit the main site as a lot of information is available there.
My main concerns, due to the lack of problems with the codebase, are turning to two other things. The design, which I have tried and tried to perfect but doesn't come off quite right, and content. The site will inevitably feed from user participation and submissions from the users, but I think a site of this size and complexity will definitely need some very devoted people to keep it fully stocked. With the issue of design, I'm contemplating asking (very nicely) a friend and colleague of mine to see what he can come up with. Either way, these concerns are trivial — I still have a lot of motivation, regardless of the criticism and comments from certain people.
rpg2knet development: nested set model
I thought, since I'm coming up to roughly the half-way mark in terms of coding, I could start using the group blog here at dovka as a devlog as well, since posts can be filtered quite easily with our tagging system. So, today I thought I'd let people know about how things are progressing. This weekend has mainly been spent working on part of the site that I have toyfully been calling Nutforge (a play on sourceforge). It is a tool for starting a game-making project, finding your team/friends with certain skills to help you work (and rating them on how useful they've been, etc), talking about your game, showing off screenshots, and uploading/releasing your game to the masses. The 'end-game' for nutforge is to have your hard work reviewed by the panel of reviewers here that we shall (hopefully) hire for rpg2knet.com, just like it happened last time.
One of the features I have implemented is a "skill set" system. Using the excellent Hierachical (Nested) Set paradigm, I've managed to come up with a tree of skills that you can tag with different levels of proficiency. The idea being, you can search for 'free' people that have listed that they are looking for a project to help out with, and order them by their proficiency, filter them out and well… cherry pick the people you like. Obviously I can foresee a problem with trolls putting all their 'proficiencies' at maximum just to clutter up the search results. With that in mind, I've been thinking about adding in a modifier system where community members can vote a member up or down in skill level if they have been involved in a project with them. That way, if somebody is a time waster, they'll essentially be flagged as such and this will warn others about undertaking a project with them.
This tiny feature is something that I consider to be, at the time of writing, very unique. I can't see any other RPG maker based website doing anything like this, although I'm aware I may have been mildly inspired by the excellent assembla.com. This is what rpg2knet.com is all about in my eyes. Something original, that nobody else has thought of, or something that nobody else can do. If all goes to plan and we can couple this website up with the sort of community spirit the old rpg2knet.com had, I believe we are really onto a winner. And that spirit is exactly what keeps me programming every night to get it completed *hurl*. As cheesy as sounds, it's true.