Chapter 2. Building the Data Tier

The data tier handles all transactions between the database and the logic tier. In this chapter, we will explore how we can build a plugin-based data tier for the CRMLive.NET mobile sales force application. A plugin-based data tier has the benefit of not having to recompile the entire application when an underlying database change needs to be done. It also serves to further increase the decoupling of the data tier from the adjacent logic tier. Different database support is provided through the distribution of small DLL (Dynamic Link Library) plugin files, which can be installed or removed by the end user depending on his or her needs. By the end of this chapter, you will have learned:

  • How to build an adaptable plugin-based data tier
  • How to set up Oracle Lite and SQL Server CE on the mobile device
  • The differences between Oracle Lite 10g and SQL Server CE 3.5
  • How to use interfaces to access Oracle Lite and SQL Server CE through the same set of method calls
  • How to connect, read, and write data to and from Oracle Lite and SQL Server CE using ADO.NET DataSets

Designing the data tier

As best practice, the logic tier only needs to describe at a higher level of abstraction, what it needs, and the data tier will do the work of retrieving the data from the database. Enter the IDataLibPlugin interface. This interface provides a set of method calls that must be implemented by both the SQL Server CE and Oracle Lite plugins. The logic tier will not need to concern itself with the low-level implementation for either database. It will make all its data requests through this interface.

The classes and their relationships in the data tier can be summarized in the following class diagram. In this chapter, you will create two forms: PluginsSetup and ConfigurePlugin that lets the user manage the list of plugins in the sales force application. These forms utilize a global class called GlobalArea (which essentially contains a single instance of the PluginManager class). The PluginManager class contains a PluginCollection object, which is a list of all the plugins installed on the device. It also contains functions to add or remove plugins, but more importantly, to save and load this whole list to and from disk.

Designing the data tier

SQL Server CE 3.5 versus Oracle Lite 10g

In a thick client application, an important factor in deciding which mobile database to use depends on what you have installed on the server as your enterprise database. Data synchronization between the device and the enterprise database is usually a job that you want to leave entirely to the database engine. For instance, it doesn't make sense to use Oracle Lite on your mobile device when your enterprise database is SQL Server because they would not be able to sync between themselves.

In the sales force application, you will be implementing both databases. There are a few differences between these two databases, which you might be interested to know. They are listed in the following table:

SQL Server CE

Oracle Lite

Microsoft provides the Microsoft Sync Framework (with SQL Server 2008) that allows you to sync a SQL Server CE database with any different database (any ADO.NET accessible database)

Oracle Lite syncs only with an Oracle database through the Oracle Mobile Server

SQL Server CE supports IDENTITY columns

Oracle Lite supports the use of SEQUENCES to implement running counters

Mobile database footprint is roughly half the size of Oracle Lite (~2.5MB)

Has a bigger mobile database footprint (~5MB)

Provides GUI-based db management tool to create and manage table schemas

Provides a GUI-based db management tool, but table schema creation/manipulation has to be done through SQL

Does not support database views

Supports database views

Note

One important consideration to note is that both Microsoft SQL Server CE and Oracle Lite do not provide support for stored procedures. Your mobile applications can, however, use parameterized queries for data access.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.14.85.76