The logical database layer and physical database layer

Links: http://www.dbatools.net/experience/logical-database-access-layer.html

    Usually our application are bound to one physical database, for example, we always read our data from specific Oracle database or MySQL database, or write business data to specific Oracle database or MySQL database. The physical database is not transparent to the application, many application developers know which physical database the data stores. But that's not so good, we'd better introduce a logical database layer between application and the pnysical database.

    We create some logical database name, and in the application code, we just use the logical database name, then we can intoduce a relation map between the logical database name and physical database, while the appliction doesn't care about the physical database location.

LOGICAL.logical database name=relation type|data source list

    In the WebChart utility, I intorudced 5 types of logical relation between the application and physical database, we may call it logical relation. The first type is equal (FIRST), always choose the first data source.

LOGICAL.WRITEDB=FIRST|masterdb

    The second type is random (RANDOM), choose one data source from the data source list randomly.

LOGICAL.SLAVEDB=RANDOM|slavedb1, slavedb2, slavedb3

    The third type is sequential (FAILOVER), if the first is unavailable (markdown), then get the next data source. We want our application read data from slave first, if no slave available then read data from master database.

LOGICAL.READDB=FAILOVER|slavedb, writedb

    The forth type is get data source by position value, the application will get the data source by a specific hash value, and we get the data source by mod it with available data source count. If we provide a hash value 5, then we will get the get the slavedfb3 connection (5%3=2).

LOGICAL.SLAVEDB=POSITION|slavedb1, slavedb2, slavedb3

    The last type is get data source by a range value, the application will get the data source by a value range. If we provide a range value 150, we will get slavedb2 connection.

LOGICAL.SLAVEDB=RANGE|slavedb1, slavedb2, slavedb3
LOGICAL.SLAVEDB.VALUES=100,200,300

    I found it may be valuable to make the application transparent to the physical databases. How do you think about it?

Comments (2)

I'm still a little confused on your entry here. Do you believe this? I do not say you are wrong, but you'll have to make a great discussion in order to convince other people that you are right.

Good, but what about the performance?

Post a comment

Remember Me?

« Previous | Main | Next »

Powered by
Movable Type 5.01