Archive for March, 2009
The free and non-free Creative Commons licenses
- Some Creative Commons licenses are ‘free’ in the sense that open source software is free.
- Other Creative Commons licenses are ‘not free’ in the sense that they restrict use of the material in ways that is counter to ‘freedom’ as defined by the Free Software Foundation or the Open Source Initiative, to draw a parallel with software licenses.
In this article I just wanted to clarify the difference for those using a CC license, so that they are not inadvertently preventing others from using their work with an unnecessarily restrictive license.
Thankfully, the creativecommons.org website now has a useful “Approved for Free Cultural Works” icon and colour scheme, to help you tell them apart. For example:
- This Attribution Share-Alike Generic 2.5 license is green and has the icon, so you know it is a ‘free’ license.
- This Attribution Non-Commercial Generic 2.5 license is yellow and does not have the icon, so it is not a ‘free’ (as in freedom) license.
Defining freedom
Creativecommons.org has chosen to adopt the meaning of ‘freedom’ as defined by Freedomdefined.org, a definition which is basically equivalent to that used for open source software. It states that for a work to be considered a free cultural work, it must have the following four freedoms:
- The freedom to use the work and enjoy the benefits of using it
- The freedom to study the work and to apply knowledge acquired from it
- The freedom to make and redistribute copies, in whole or in part, of the information or expression
- The freedom to make changes and improvements, and to distribute derivative works
Freedom applies to everyone
For these freedoms to be valid, they must be unconditional and apply to everyone, regardless of who they are or what they intend to use the work for. This means that any license with a non-commercial clause is not free in the sense that any business wanting to use the work commercially would have to make a separate arrangement with the author. One of the basic rules of open source software is that businesses are allowed to use it in order to profit from it; if what they could do with it was restricted, open source software would be avoided by commercial enterprises. Companies wouldn’t be installing Linux on their clients’ systems, for example.
The same applies to non-software cultural works: allowing anyone the freedom to use the work, regardless of whether they intend to profit, enables businesses to assist the proliferation of the work.
Freedom includes freedom to make changes
These freedoms also include the freedom to make changes and improvements. If a license does not allow derivative works, it is another example of restricting users’ ability to do whatever they like with the work. The ability to modify the work is seen as advantageous for the community because it allows the work to be improved by others, without a separate arrangement being made with the original author. To draw a comparison with open source software again, if businesses were not allowed to modify Linux and provide their own version of it, many businesses would not be able to exist, and the behaviour of Linux would be entirely under the control of a single entity. Allowing others to modify your work allows businesses to exist that support the work through improving it.
Some restrictions are still acceptable
Requiring copyright notices to be preserved, or requiring any derivative works to be given the same license (a share-alike clause) are still considered acceptable restrictions by the free software movement and free cultural works. It’s just that any restrictions beyond this, such as preventing commercial uses and preventing any modifications, are not.
Quick guide to choosing a Creative Commons license
There is nothing wrong with choosing a non-free license for your work: It is the creator’s right not to license their work, or to apply any restrictions they desire. If you are considering releasing something under a Creative Commons license, you should consider which rights you want to retain. One reason for retaining a right would be if you want to make money from it.
So, here’s a quick guide on how to choose between the licenses:
- Including a non-commercial clause allows you to retain the sole right to make money from distributing the work. If allowing others freedom to use the work is more important to you than making money, then don’t include a non-commercial clause.
- Not allowing derivative works allows you to retain the sole right to alter the work, which allows you to reserve the right to charge money for or prevent alterations. If allowing others to use and improve the work is more important to you that making money from or preventing alterations, then make sure you allow derivative works.
- If you do not care about money, or controlling who is allowed to do what with the work (save put a copyright notice on it), but you do care that the work is free for all to use and modify how they see fit, then make sure the Creative Commons license you choose is a green one, with the ‘Approved for Free Cultural Works’ icon. This will ensure that your work receives the best chance of being re-used and shared by as many people as possible.
Add comment 9 March, 2009
Storing hierarchical data in a database using ancestor tables
More of a ‘programmy’ topic today – this one about storing hierarchical data (data that could represent a tree) as records in a relational database.
There’s plenty of information on the web about storing hierarchical data in SQL using these methods:
- Adjacency list
- Materialised paths
- Nested sets
The method I used in a personal project of mine, however, is different to all of these. Today I found this Evolt article, which pretty much describes the technique I’m using, calling it ancestor tables.
I don’t know if it’s just because I don’t know the right name for it, or if people just generally haven’t thought of it, but finding anybody using this method has been pretty difficult – for whatever reason, nested sets (which I believe has serious flaws) and materialised paths seem to be all the rage instead.
First, I’ll describe each of the alternative methods in brief. More information is available in this article from DBAzine, though you can find an easier to understand description of nested sets in this one from MySQL.
Brief descriptions
An adjacency list just means that for each node, you also store the ID of its parent node. It’s easy to write a query to find immediate parents or children of an node using this method, but finding a list of ascendents of descendents, including non-immediate ones, requires some sort of fancy recursion. That’s a well acknowledged limitation of this method, and if you look around the web you’ll find a lot of people pointing this out, at the same time singing the praises of nested sets as if they’re the only alternative.
A materialised path means that for each node, you store a string which represents the path to that node. For instance, the node with id 13 might have a path of ‘1.2.12′, meaning that it is the immediate child of 12, which is the child of 2, which is the child of 1. This opens up a few more possibilities in terms of efficient queries that can be made. For example, you can easily find all descendents of an node using a WHERE path LIKE ‘1.2.%’ type of syntax, or just WHERE path=’1.2′ if you only want immediate children. Efficiently finding ancestors is still a bit fiddly, as is moving an node to elsewhere in the table, but it’s not unmanageable. I actually think it’s a good solution.
Nested sets are more complicated than any other method. For each node, you store two integers, which represent a ‘range’. The ‘root’ node of the tree contains the lowest and highest numbers of the whole tree, and each branch contains the lowest and highest number of that branch. It’s probably easiest to illustrate this with a diagram (which I found in this article). Each number between the lowest and highest is used once and only once in the whole tree. The major benefit to this is that it makes finding all descendents of a node fairly efficient. To find children of an node, just find all nodes WHERE leftvalue > parent.leftvalue AND rightvalue < parent.rightvalue. It’s highly inefficient, however, when you only want immediate children, ie only a single level of descendents. It also lets you down substancially when making any modification to any node in the tree; any creation, deletion or moving of an node will always require, on average, half of the rows in the whole table to be updated. Good if the tree is very small or you never plan to update it; bad otherwise.
Variations of nested sets exist which attempt to solve some of its problems, but these tend come at the cost of even greater complexity. I was reading about a method with ever decreasing fractions for increasing levels of the tree earlier.
Ancestor tables
My ancestor tables method can probably be thought of as similar to a materialised path, in that it requires about the same amount of information, except that it doesn’t concatenate it all together into a string to be stored in a single column value, but represents each ancestor in its own row in a separate relation table:
- ancestor_ID (int)
- node_ID (int)
- level (int)
For each node added to the tree, you add rows to this ancestor table describing its ancestry. So for example, if node 13 is the child of 12, which is the child of 2, which is the child of 1, this would be represented in the ancestor table as:
| ancestor_ID | node_ID | level |
|---|---|---|
| 1 | 13 | 3 |
| 2 | 13 | 2 |
| 12 | 13 | 1 |
The total number of rows needed in this ancestor table is related to the number of ancestor-descendent relationships in the whole tree. If your average node is nested only 4 levels away from the root node, then you only need about 4 times the number of nodes. It’s much less even than O(n log n).
(When I do it, I also includes a 0th level for each node, where ancestor_ID equals node_ID and level is 0. There was only one edge case where this helped me for my specific project.)
The method allows for all of the following queries to be efficient, requiring no recursive joins or multiple queries.
- Find the parent of a node:
SELECT ancestor_ID FROM ancestors WHERE node_ID=<nodeid> AND level=1 - Find all ancestors of its node, including its parent, and each parent in turn:
SELECT ancestor_ID FROM ancestors WHERE node_ID=<nodeid>
- Find all the immediate children of a node:
SELECT node_ID FROM ancestors WHERE ancestor_ID=<nodeid> AND level=1 - Find all the descendents of a node, including all immediate children and their descendents:
SELECT node_ID FROM ancestors WHERE ancestor_ID=<nodeid>
As you can see, none of these queries need recursive joins, or require the database to inspect more rows than they need to, and none of them even require looking up certain information (such as the path to the requested node, or left and right values) before actually doing the query that returns the rows.
Add a LEFT OUTER JOIN to your main node table, and you can fetch all the necessary data about each node (name, properties, etc) in the one query.
You can even do efficient sorting via the same index used to fetch the rows, as long as you add columns to the ancestor tables for whatever data you want to sort on and use indexes wisely.
It also means that when inserting a new node, or making another edit to the tree, you do not have to modify the majority of the tree – only the entries in the ancestor tables that belong to that node. This is similar to the materialised paths technique, where you only need to update the path for the node you change.
2 comments 6 March, 2009
Thumbs up/down, the simplest form of user feedback
Users really appear to love being able to give a ‘thumbs up’ or ‘thumbs down’ to any statement they see on a website.
Strongly disagree with a YouTube comment? Give a thumbs-down! You have expressed an opinion in only a single mouse-click!
The ease of expressing pleasure or displeasure upon someone else’s opinion in a single click seems to be a highly effective way of getting feedback from your users, because it exploits their desire to have their say, at the same time reducing the barrier of entry: typing a reply in words is no longer necessary, neither is logging in, filling out a form, or even visiting a different page.
Harness the crowd’s wisdom
Simple feedback systems like this can even serve as a n0-maintenance extension to your comment moderation: enough down-votes, and your system can be pretty sure, without you even reading it, that a comment is offensive or irrelevant enough to be removed. A YouTube comment with many down-votes appears hidden by default – depending on how many, you may still be able to view it, but it’s highly likely to be offensive or spam. It appears to be pretty effective. Users are willing to do your moderation for you even if they get nothing in return other than the satisfaction of showing their approval or disapproval.
Getting feedback on a blog in the form of comments is very difficult: for every thousand people who read something, a tiny fraction will go through the effort required to fill in their name and write out a proper response, even if you have a comment form that requires no approval or sign-up. If you are writing something highly controversial or offensive, or taking a side on a ‘hot topic’ (Apple sucks, Microsoft is better) you’ll probably find that tiny fraction rise substancially, but otherwise eight hundred people could read a blog post before anyone comments. So, given that it is so hard to get any feedback by comments, why not allow one-click feedback?
Characteristics
What I think of as the YouTube model is not unique to YouTube: Facebook uses the same sort of thing, so does Digg (of ‘digg it’ fame), and my new favourite StackOverflow does the same sort of thing too (though you need reputation to vote), and many others – sadly, sites such as WordPress.com haven’t followed yet. The basic characteristics of this model are:
- One click ‘vote up’ or ‘vote down’ buttons next to comments.
- Clicking them records your vote instantly without a page refresh (Ajax techniques are used).
- There is usually some way that voting something ‘down’ penalises it; it may cause it to move further down the page, or a certain number of down-votes may ‘hide’ it.
I like it so much that when I find myself reading user comments and I can’t give it a thumbs-up or thumbs-down, it frustrates me; I’ve come to expect to be able to give one-click feedback.
Previous experience
The success of Hot or Not and a whole generation of clones showed the addictive popularity of giving users the ability to give feedback with no more intellectual effort than a single click. Instead of a single up-vote or down-vote, however, the user had to choose a value out of ten, and while it only required a single click, it did result in a page load. Nevertheless, people spent hours and hours on sites following that model. While originally they were rating photos of people based on looks, the concept spread to rating all sorts of other things, like graphic design work, poetry, and jokes.
I believe that the thumbs up/down approach takes this two steps further – by reducing the number of available choices down to two instead of ten, and by accepting the feedback without a page reload (due to Ajax techniques).
Years ago I implemented a rating system on a website of my own, making a conscious decision to reduce the number of possible choices from ten down to only three. My belief at the time was that it was a sweet spot, between getting enough useful information from users, and being simple enough so that as many users as possible would use it, because it was such a no-brainer. Adding the voting option under each piece of content did result in participation and increase page views per user. In retrospect, I could have reduced it further to a single ‘up-vote’ and ‘down-vote’, and I suspect the participation rate would have been even higher due to the lower mental effort required. The ‘results’ allowed me to rank items on the site according to popularity; the front page item was always one of the most ‘popular’ in terms of votes.
As I publish this, I just noticed that WordPress.com allows nested comments now – maybe they can allow ratings on comments one day soon!
Add comment 5 March, 2009