I've been thinking a bit more on my database design sense this post. The general idea is I'de like to create a generic database that can store information on any number of subject, similar to a wiki, but have more structured data available to help. The idea is that the linking between entries will be more defined and allow more more types of searches.
Library -- Primary library entry data
iD VARBINARY(16) -- UUID & PK
ownerID VARBINARY(16) -- Users UUID & FK
name VARCHAR -- Name for the entry
dataType VARCHAR -- Mime type of data
data LONGBLOB -- Data a for the entry
dirty BIT -- Was this entry locally modified
timestamp DATETIME -- Last time the record was updated
Sections -- Additional sections for a library entry
iD VARBINARY(16) -- UUID & PK
libraryID VARBINARY(16) -- Library UUID & FK
name VARCHAR -- Name for the section
order int -- The ordering of this section
dataType VARCHAR -- Mime type of data
data LONGBLOB -- Data for the section
dirty BIT -- Was this section locally modified
timestamp DATETIME -- Last time the record was updated
Attributes -- Attributes for a library entry
iD VARBINARY(16) -- UUID & PK (Potentially could be removed)
libraryID VARBINARY(16) -- Library UUID & FK
name VARCHAR -- Name of attribute
dataType INT -- The type of data the attribute holds
reference VARBINARY(16) -- Value of attribute that is Library UUID & FK
data VARCHAR -- Value of attribute that is any other datatype
dirty BIT -- Was this attribute locally modified
timestamp DATETIME -- Last time the record was updated
Users -- User accounts
iD VARBINARY(16) -- UUID & PK
libraryID VARBINARY(16) -- Library UUID & FK (The library entry for this person)
email VARCHAR -- Email address
nickname VARCHAR -- Nickname used for display
firstname VARCHAR -- Real first name
lastname VARCHAR -- Real last name
joinDate DATETIME -- Date the account was created
OpenID -- Mapping for OpenID authentication
openID_URI VARCHAR -- PK
userID VARBINARY(16) -- Users UUID & FK
I've added a Sections table to hold individual sections of an entry. Sections should be used to break down an entry into logical parts when it makes sense to do so. This would allow for automatic generation of table of contents, possibility to show/hide individual sections, the ability to update a section without having to update the whole entry.
I've also added a Uses table and an ownerID to each entry. The thought is that the own would have the ability to approve edits made to the entry. The owner would/should be an expert in the subject area of the entry. I'm contemplating a social aspect with reputation similar to stackexchange to limit/allow the user to edit entries that aren't their own. I'm still thinking this through so any thought on the matter would be nice.
Standard attributes that apply to all Library entries are below. Besides these two each entry could have any number to attributes that only apply to it. I'm not sure how to store the information yet but I would like to be able to define standard attributes for given types of entries. For example all entries on people should have a Birthdate attribute.
Attribute Name | Type | Description
---------------+------+---------------
TypeOf | ref | The Library entry UUID that this attributes library entry is a type of.
| | For example if this attribute's library entry is for the element
| | carbon then the TypeOf attribute would point to the library entry for
| | elements. There can only be one TypeOf attribute.
---------------+------+---------------
Tag | ref | The Library entry UUID that this attributes library entry relates to in
| | some way. These are meant to work in the same way tags in a tag cloud work.
| | There can be multiple Tag attributes.
---------------+------+---------------
General design thoughts? I'm trying to design a database that can store information on anything and allow for meaningful and useful searches. The idea is this could old an encyclopedia or two worth of information allowing for the data to be structured in such a way as to allow easy navigation from like/similar/related item to item.
How should revisions be handled?
- Drop all history, only modify the current entry
- Each revision is in effect a new entry (duplicating all other sections/attributes needed for the entry)
- Create a History table to keep previous version of the data without the need to create a new library entry for each revision
- Something else
Given the above design what issues may arise during syncing 2 separate databases?
- Entry Exists -> Entry Doesn't Exist
- Updated Entry Exists -> Entry Exists
- Updated Entry Exists <-> Updated Entry Exists
- Are this security issues with syncing the Users and or OpenID table
In the above design how would you handle merging 2 entries while keeping both existing entries intact? What issues may arise with merging entries?
- Create a pointer from one to the other
- Create a 3rd new merged entry
- Something else