Dec 22, 2007

Data Persistence Framework

To expand further on a rapid web application framework, we also need a complementary data storage mechanism.

In today's world, most data is persisted in RDBMS's like Oracle, Sql Server, DB2, Sybase etc. In my opinion most of the applications do not need to have dedicated schema for storing objects.

Instead they can make use of a tuple based design for storing various object instances. A tuple and its related operations can be defined succinctly using a Xml grammar (like given below:).

<AppObject1>
<Meta>
<Attribute1 key="yes" type="int"/>
<Attribute2 key="yes" type="string"/>
<Attribute3 type="datetime"/>
</Meta>
<Upsert name="CreateEntity">
<Attribute1>@Attribute1</Attribute1>
<Attribute2>@Attribute2</Attribute2>
<Attribute3>@@getdate()</Attribute3>
</Upsert>
<Select name="GetEntities">
<Attribute1/>
<Attribute2/>
<Attribute3>@@getdate()</Attribute3>
</Select>
</AppObject1>

This Xml format or notation can be generalized across a whole class of problems. It fits the relational model quite nicely too. For example, one can imagine a database table having the following schema:

0. AppObjectId BIGINT
1. AppObjectName NCHAR(50)
2. Type NCHAR(50)
3. SubType NCHAR(50)
4. Bigint0 BIGINT
...
13. Bigint9 BIGINT
14. Decimal0 NUMERIC(18,6)
...
23. Decimal9 NUMERIC(18,6)
24. String0 NVARCHAR(2000)
...
33. String9 NVARCHAR(2000)
34. TextDataId BIGINT
35. CreatedBy BIGINT
36. CreatedDate DateTime
37. UpdatedBy BIGINT
38. UpdatedDate DateTime

No comments: