views:

22

answers:

1

Is there an existing implementation or even a name for a type of database which allows multiple points of view? What I mean is for instance if one user changes an article's title then the change will only be visible to that particular user and everyone else will see the original title. If several users change it to the same new title then the new title becomes the 'master view', or the 'unfiltered view' of the database, initiated either by the database or from the application.

I'm coding in C# and am familiar with SQL and starting with MongoDB but the question is about the concept and whether abstractions, implementations, or design patterns of it exist.

A: 

If your "point of views" are completely separated, you could just use a new database for each user.

From your question it seems you want to have some degree of interconnectedness. Perhaps articles created by any user should be visible to everyone? Is it only changes after creation that should be private? How about updates from the original author?

I think you just need to specify the behavior you need, and design a database that can handle that.

One solution could be to use both the (article) id and the user id as the key for your tables. That way you can completely replace content for specific users. Let's say you want to find article 123, as seen by user 456, or if that user doesn't haven't edited it, as seen by user 789, or if that user haven't edited it, just pick any version:

SELECT * FROM articles WHERE id = 123 ORDER BY user_id = 456 DESC, user_id = 789 DESC LIMIT 1
geon
That's a trivial solution for UPDATE changes but when you start considering DELETEs and the conflicts in views they may create it starts to become not so trivial. I can model my database to handle all the complications of multiple points of view but it will be quite application specific and I was wondering if there already was an existing CRUD abstraction of a multiple point of view data model. In other words has anyone already solved the general problem?
Eff Snarf
"conflicts in views" is pretty much what you are trying to achieve. You might want to look at the immutable datastructures used in functional languages such as Haskell.
geon
conflicts will arise in operations, as in if a user deletes an article and another user renames it then the rename operation can only be applied to user2 and to the master view but not to user 1.
Eff Snarf
I think you need to clarify what you want to achieve. You specifically stated that " the change will only be visible to that particular user".
geon