Core db framework
-
Upload
sean-xiong -
Category
Technology
-
view
567 -
download
3
Transcript of Core db framework
CoreDB
A plug-in based, extensible database solution.
By Huangtao (Sean) Xiong (Now Research Engineer at NICTA)
Xu Zhao (Now Software Engineer at Ryarc Digital)
Van Munin Chhieng (Now Software Engineer at MQ Group)
Service Oriented Computing Research Group
School of Computer Science And Engineering
Architecture
Overview
Performs powerful object relational mapping. Offers developers:
Query on databases – CoreDB Base Trace historical data – CoreDB Tracing Apply security policies – CoreDB Security And do fulltext search – CoreDB FulltextSearch
programmatically.
CoreDB Object Relational Mapping
Abstracts relational databases to java objects:
Database – DatabaseSchema
DB tables – EntityClass
DB table column – AttributeClass
Table data row – EntityInstance
Easily build DB connection and generate DB mapping
By creating EntityController Object
String path = “credential.txt”; // stores DB connection parameters
IEntityController iec= new EntityController(path);
No Mapping configuration file, all mappings stored in memory
No table beans and daos will be generated
Get Table definition object by calling EntityClass ec = iec.getEntityClass(tableName);
Get Table columns object by calling ec.getAttributeClasses();
Or get particular column: iec.getAttributeClass(tableName, columnName);
CoreDB Base
Query on Database (CRUD Operations) CRUD on Data:
CoreDB Base offers developers to create, read, update and delete data rows and do joins among tables programmatically.
CRUD on Data Schema:
CoreDB Base offers developers to create tables, get table definitions, update tables (add/update/delete columns) and delete tables programmatically
Example – Create a data row
// set the table name
String tableName = “the name of table”;
// create entity instance object for the table
EntityInstance entity = iec.createEntityInstanceFor(tableName);
// to set the value of columns
entity.set(columnName, columnValue);
//for example, set value for a string type column 'FirstName'
entity.set("FirstName", “John”);
// Insert into DB
iec.createEntity(entity);
Example – Create a table
// Create a list of AttributeClasses (Columns)
List<AttributeClass> acl = new LinkedList<AttributeClass>();
AttributeClass ac = AttributeClass(“ColumnName”, Integer.class);
ac. setPrimaryKey(true); ac. setAutoIncrement(true);
acl.add(ac);
// Create index for table
List<IndexClass> icl = new LinkedList<IndexClass>();
IndexClass indexClass = new IndexClass(ac, true); // true means unique index
icl.add(indexClass);
// Create an EntityClass Object (table)
EntityClass ec = new EntityClass(“TableName”, acl, icl);
// Create table in DB
iec.deployDefinition(ec);
CoreDB Tracing
Extends CoreDB Base Developers can read all the historical data and know
who is the operator for every data modification Can be easily applied on existing Data tables.
By calling iec.initializeMode(true, Mode.TRACING);
Do not do any modification on existing Data tables Can be easily de-tracing – remove tracing.
User Case
John Simth is the CEO of company A and he has been worked in A for 12 years. He was promoted twice from Manager to Director (in 2000) and then CEO (in 2004) over the past 12 years.
HR's record in data table 'employee'
ID FN LN DOB Address Tel Title Salary Start date
001 John Simth 13/07/1963 Queens st 1234567 CEO 500 k 02/02/1999
User Case with Tracing
HR's record in data table 'employee'
001 John Simth 13/07/1963 King st 1234567 Director 300 k 02/02/1999 Linda 02/02/2001
001 John Simth 13/07/1963 Park St 1234567 Manager 150 k 02/02/1999 Linda 02/02/1999
HR's tracing record (between 01/01/1999 and currnet)
ID FN LN DOB Address Tel Title Salary Start date Last Updated By
Last Update Date
001 John Simth 13/07/1963 Queens st 1234567 CEO 500 k 02/02/1999 Linda 04/04/2004
ID FN LN DOB Address Tel Title Salary Start date
001 John Simth 13/07/1963 Queens st 1234567 CEO 500 k 02/02/1999
CoreDB Security Extends CoreDB Base
Offers data access controlling (CRUD)
Controlling on users User group level user level
Security on Data Data rows Table columns
Can be easily applied on existing Data tables.
By calling iec.initializeMode(true, Mode.SECURITY);
Do not do any modification on existing Data tables
Can be easily removed
User Case with Security
HR's record in data table 'employee' (Viewed by HR Administrator)
ID FN LN DOB Address Tel Title Salary Start date
001 John Simth 13/07/1963 Queens st 1234567 CEO *** 02/02/1999
ID FN LN DOB Address Tel Title Salary Start date
001 John Simth *** Queens st 1234567 CEO 500 k 02/02/1999
ID FN LN DOB Address Tel Title Salary Start date
001 John Simth *** *** 1234567 CEO *** 02/02/1999
HR's record in data table 'employee' (Viewed by Payroll Adviser)
HR's record in data table 'employee' (Viewed by other employees)
CoreDB Fulltext Search
Extends CoreDB Base
Applies Fulltextsearch on tables OR table columns
Index data can be stored in DB, File or Memory
Easily build FTS index and remove FTS index
Supports CUD operations with index
Supports FUZZ read and result Entities will be sorted by similarity
Compatible with Luence Query Syntax
What's the next?
CoreDB DataCube Researcheres and Engineers in SOC are working on
CoreDB extensions Probably will be open source soon????
Thank you!
Questions are welcome!!