Hi,
A long time ago I took over maintenance of a web based content management system that had a pretty clever database table in it.
The table structure was like:
TABLE: tPage (PK on PageID, Version, Status)
PageID, PageTitle, Version, Status
1, Homepage, 1, Archived
1, Homepage, 2, Live
1, New Home, 3, Draft
TABLE: tElements (PK on PageID, Version, ElementName)
PageID, Version, ElementName, ElementValue (nText)
1, 1, IntroText, Hi, this is our first version.
1, 2, IntroText, This is the current version,
1, 2, MainBody, We sell sprockets.
1, 3, IntroText, Welcome text here
1, 3, MainBody, We sell sprockets and widgets.
To get the main body text of the current homepage you'd write a query like:
Query:
SELECT ElementValue
FROM tElements, tPage
WHERE PageID = 100
ElementName = 'MainBody'
AND tPage.PageID = tElements.PageID
AND tPage.Version = tElements.Version
AND tPage.Status = 'Live'
Result:
We sell sprockets.
The beauty of this table structure, (to me at least) was that I didn't need to add new columns to a table when I wanted to add new types of data. I just created a new ElementName. But functionally it was like a new column.
I've since used this arrangement in a few other projects where I needed a database that would change easily as new features/content types would be added. For example, in my above CMS example, we started with just IntroText, and MainBody, but by a few years later we ended up with CoursePrice, ContactPerson, RelatedCourses, SetupFee, and I found this way of organising our data to be very flexible.
My question is, what is this type of table structure called? I'm not really sure what keywords I should be googling for more information.