Anybody are conscious of an API (php more suitable but I'd want to consider any language) for creating wiki-like data storage?

What about any assets on moving your personal plaintext wiki? How can other plaintext wikis handle the format from the text file?

I realize I'm able to use Markdown or Textile for that formatting. But what I am most thinking about is how you can approach the plaintext storage of multi-user edits.

I am writing an internet application that's mainly database driven. I would like a minumum of one text area of the database to stay in a wiki-like format. Particularly, this text could be edited by multiple customers having the ability to roll to any version. Think the wiki/bio portion of Last.FM (almost the whole website is strictly structured with a database aside from that one section per artist).

To date, my approach of taking apart MediaWiki and wedging it right into a database appears like overkill. I am thinking it might be much simpler to roll my very own plaintext wiki, and store this file within the database's appropriate text area.

So, essentially this can be a "how do you version text information during my DB".

Well, the easiest strategy is simply copying the information.

Simply, produce a "version" table that holds "old versions" from the data, and link it to your primary table.

create table docs {
    id integer primary key not null,
    version integer not null,
    create_date date,
    change_date date,
    create_user_id integer not null references users(id),
    change_user_id integer references users(id),
    text_data text

create table versions {
    id integer primary key not null,
    doc_id integer not null references docs(id),
    version integer,
    change_date date,
    change_user integer not null references users(id),
    text_data text

If you improve your original document, you copy that old text value directly into this table, copy the consumer and alter date and bump the version.

select version, change_date, change_user, text_data 
    into l_version, l_change_data, l_change_user, l_text_data 
from docs where id = l_doc_id;

insert into versions values (newid, l_doc_id, l_version, 
    l_change_date, l_change_user, l_text_data);

update docs set version = version + 1, change_date = now, 
    change_user = cur_user, text_data = l_new_text where id = l_doc_id;

You can even do that inside a trigger in case your DB supports individuals.

Problems with this particular method are that it is a complete copy from the data (if you possess a large document, the version stay large). You are able to mitigate that by utilizing something similar to diff(1) and patch(1).

For instance:

diff version2.txt version1.txt > difffile

You'll be able to store that difffile as "version 1".

To be able to recover version 1 from version 5, you grab the version 5 data, run patch onto it while using diff file data, which provides you with v1.

If you wish to move from v3 to v1, you must do this two times (once to obtain v2, and on the other hand to obtain v1).

This reduces your storage burden, but increases your processing (clearly), so you will need to judge how for you to do this.

Will's huge response is directly on, but could be summed up, I believe: you have to keep versions, and you have to keep metadata (who what when from the data).

However your question involved assets on Wiki-like versioning. I've none (well, one: Will's answer above). However, concerning the storage of Wikis, I've one. Take a look at the comparison matrix from DokuWiki. I understand. You are thinking "exactly what do I care what make of DB different Wikis use?" Because DokuWiki uses plain text files. You are able to open them and they're indeed plain. So that's one approach, and they have got a bit of interesting arguments why DBMS aren't the easiest method to go. They do not even hold much metadata: the majority of the stuff is performed with the flat files themselves.

The purpose of the DokuWiki for you personally is the fact that whether it's a easy problem (for the way well you need to solve it :)

Here's a listing of 12 wikis on WikiMatrix which are designed in PHP and do their storage using text files. Possibly one of these may have a storage method you are able to adapt in to the database: