I'd like to understand how a wiki works, at least from a high level. When a user saves changes, does it always insert a new row in the database for that wiki article (10 revisions, 10 rows in the database).
Yes, it does. Otherwise it will be impossible to see full page history, which is what's expected from a Wiki implementation.
Every entry inside of the wiki is a new entry inside of the database. That way revisions can be tracked. It is all about the community and tracking. Behind the scenes the database is storing datetime, changes made, etc.
Yes.
...
Seems a bit short. Let's just say that you have to store the original article and then details about each change afterwards. So you might have an Article table and a Revision table. That way you can roll back to any prior state.
Of course the design of the tables, the logic behind stripping revised text from the original and storing this separately is pretty complex.
Here is the dev blog for TWiki that might give you some useful information. http://twiki.org/cgi-bin/view/Blog/WebHome?category=Development.
Is Sql a requirement of the project? There is a lot of movement around NoSql at the moment and a wiki seems to fit nicely into the document store database. Some information on this can be found here http://nosql-database.org/.
There is a implementation on Codeplex at http://wikiplex.codeplex.com/. This is from another post on stackoverflow http://stackoverflow.com/questions/1064925/asp-net-mvc-wiki.
I agree with all the answers. Wikis normally handle every edit as a new record inside the database.
You may be interested in checking out the full Layout of the MediaWiki database diagram, the wiki engine behind Wikipedia.
Note that the full text of each revision is stored in a MEDIUMBLOB
field in the text
table.
I just wrote a wiki in C# actually. One thing I would add to everyone else's comments is that you'll want to make sure you can compare two versions. For doing this in C# I strongly suggest the C# implementation of the diff_match_patch library from Google. It's quite fast and it's quite easy to extend if you need more in the way of pretty printing or handling of structured text like HTML.
You might want to check if maybe a version control engine can be used for the text parts (Users etc might still need a database) as most version control systems have all the necessary functions implemented (history, diffing, log entries for changes, ...) which would save you a lot of work.