Top Banner
A Study on Mobile-Application Database using FireDac Adina, Jayson Jenrie R. #35 Tabora Street, Trancoville, Baguio City, Benguet 074-443-81-33, 2600 [email protected] Chacapna, Teodorico D. Abatan, Bauko Mountain Province 09467676688l, 2621 [email protected] ABSTRACT In today's aggressive business environment, organizations are looking for competitive advantages in all areas of their business. Every department in an organization, including IT, is being asked to improve their processes and increase the overall competitiveness of the business. Every department/unit must view itself as crucial to an organization's success. The fast moving and production of development on mobile devices in the consumer market has forced the software engineering to adapt development approaches conscious of the capabilities of mobile applications on the different database applications. In this paper our aim is to conduct a comparative study on Mobile-Application Database using FireDac. We will focus on interface, connection, benefits, design and set-up, and deployment of application to mobile devices. Moreover we will provide a step by step procedure or Tutorial in installing the FireDac and SQLite Compatibility in Mobile Application for accessing the library through the database. Keywords Mobile Application; Web Based Application; Database Mobile Platform, FireDac, DBExpress, SQLite, Database Procedures, Tutorial, Delphi, C++ 1. INTRODUCTION Increasingly, organizations now a days are looking for new ways to improve their productivity and competitiveness. One area is through mobile computing. A well-designed mobile application can enable an organization's to be more productive and competitive by deliver improved customer service while reducing operating costs. However, mobile applications require innovative approaches to employing critical business applications and data. Any data or application that is used must integrate with and leverage an organization's existing application and database infrastructure. There are two primary models for mobile applications: online applications and occasionally connected smart client applications. Online applications require a network connection to a backend enterprise data source, and are usually browser-based. Occasionally connected smart client applications are characterized by a local data store and local application, and do not require a constant network connection. Each of these models has advantages and disadvantages. It is important to understand these advantages and disadvantages so that the appropriate model can be chosen for a given business needs.
19
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: A Study on Mobile-Application Database Using FireDac

A Study on Mobile-Application Database using FireDac

Adina, Jayson Jenrie R.#35 Tabora Street, Trancoville,

Baguio City, Benguet074-443-81-33, 2600

[email protected]

Chacapna, Teodorico D.Abatan, Bauko

Mountain Province09467676688l, 2621

[email protected]

ABSTRACTIn today's aggressive business environment, organizations are looking for competitive advantages in all areas of their business. Every department in an organization, including IT, is being asked to improve their processes and increase the overall competitiveness of the business. Every department/unit must view itself as crucial to an organization's success. The fast moving and production of development on mobile devices in the consumer market has forced the software engineering to adapt development approaches conscious of the capabilities of mobile applications on the different database applications.

In this paper our aim is to conduct a comparative study on Mobile-Application Database using FireDac. We will focus on interface, connection, benefits, design and set-up, and deployment of application to mobile devices.

Moreover we will provide a step by step procedure or Tutorial in installing the FireDac and SQLite Compatibility in Mobile Application for accessing the library through the database.

KeywordsMobile Application; Web Based Application; Database Mobile Platform, FireDac, DBExpress, SQLite, Database Procedures, Tutorial, Delphi, C++

1. INTRODUCTIONIncreasingly, organizations now a days are looking for new ways to improve their productivity and competitiveness. One area is through mobile computing.

A well-designed mobile application can enable an organization's to be more productive and competitive by deliver improved customer service while reducing operating costs. However, mobile applications require innovative approaches to employing critical business applications and data. Any data or application that is used must integrate with and leverage an organization's existing application and database infrastructure.

There are two primary models for mobile applications: online applications and occasionally connected smart client applications. Online applications require a network connection to a backend enterprise data source, and are usually browser-based. Occasionally connected smart client applications are

characterized by a local data store and local application, and do not require a constant network connection. Each of these models has advantages and disadvantages. It is important to understand these advantages and disadvantages so that the appropriate model can be chosen for a given business needs.

1.1 Aim of Research

In this paper, the researchers will discuss the comparison of the Mobile Application Databases using FireDac. We will focus on interface, connection, benefits, design and set-up, and deployment of application to mobile.

1.2 Mobile DatabaseA mobile database is either a stationary database that can be connected to by a mobile computing device (e.g., smartphones, tablets and PDAs) over a mobile network, or a database which is actually stored by the mobile device. This could be a list of contacts, price information, distance travelled, or any other information.

Many applications require the ability to download information from an information repository and operate on this information even when out of range or disconnected. An example of this is your contacts and calendar on the phone. In this scenario, a user would require access to update information from files in the home directories on a server or customer records from a database. This type of access and work load generated by such users is different from the traditional workloads seen in client–server systems of today. Mobile databases are not used solely for the revision of company contacts and calendars, but used in a number of industries.

2. RESEARCH METHODOLOGY

Record Retrieve Analyze Create

Figure 1. Collecting Data Research Methodology

For most research projects the data collection phase feels like the most important part. However, you should avoid jumping straight into this phase until you have adequately defined your research problem, and the extent and limitations of your research. If you are too hasty you risk collecting data that you will not be able to use.

Page 2: A Study on Mobile-Application Database Using FireDac

Consider how you are going to store and retrieve your data. You should set up a system that allows you to:

record data accurately as you collect it;

retrieve data quickly and efficiently;

analyse and compare the data you collect; and

create appropriate outputs for your dissertation e.g. tables and graphs.

There are many systems that support effective data collection and retrieval. These range from card indexes and cross-referenced exercise books, through electronic tools like spreadsheets, databases and bibliographic software, to discipline-specific tools. You should talk about how you plan to store your data with your supervisor, an information librarian, or a study adviser in the Learning Development. As you undertake your research you are likely to come up with lots of ideas. It can be valuable to keep a record of these ideas on index cards, in a dedicated notebook, or in an electronic file. You can refer back to this ‘ideas store’ when you start to write. They may be useful as ideas in themselves, and may be useful as a record of how your thinking developed through the research process.

2.1 Mobile Database Application Consideration

Mobile users must be able to work without a network connection due to poor or even non-existent connections. A cache could be maintained to hold recently accessed data and transactions so that they are not lost due to connection failure. Users might not require access to truly live data, only recently modified data, and uploading of changing might be deferred until reconnected.

Bandwidth must be conserved (a common requirement on wireless networks that charge per megabyte or data transferred). Mobile computing devices tend to have slower CPUs and limited battery life. Users with multiple devices (e.g. smartphone and tablet) need to synchronize their devices to a centralized data store. This may require application-specific automation features.

This is in database theory known as "replication", and good mobile database system should provide tools for automatic replication that takes into account that others may have modified the same data as you while you were away, and not just the last update is kept, but also supports "merge" of variants. Users may change location geographically and on the network. Usually dealing with this is left to the operating system, which is responsible for maintaining the wireless network connection.

2.1 Best Practices of Mobile Database Application“Author”

2.0.1 Choose Your Mobile Database and Data Synchronization Infrastructure

2.0.2 Tutorial on Mobile Database and Synchronization Infrastructure

2.0.3 Analyze on the Database Application Development Approach.

2.3 Online Application DatabaseAn online application does not store any data or application logic on the mobile device. Therefore, when the user requires access to the application and data, a network connection is required. Typically with mobile devices, this network connection is wireless, either WiFi or Wide Area Network (WAN). All data and applications are transmitted through this wireless network connection only when requested by the user.

2.1.1 Advantages: The main advantage of this model is that there is no data or application actually stored on the device, outside the organization's data center. When data is required, it is retrieved directly from the enterprise's back-end data store. Because of this, there is no software distribution to the mobile device and the user will see enhancements to the application as soon as they are made on the central server. Security is seemingly easier to manage because no data is actually stored on the mobile device.

2.1.2 Disadvantages: There are some significant disadvantages to the online model that primarily occur in two areas: user expectations and network communications. A user's primary expectation is that the application and data will always be available. But with an online application, the user must have wireless network coverage. If the user is located in an area without network coverage, the application cannot be used and if the connection is slow or unstable, use of the application can be frustrating at best. Because online applications require communication over a wireless network, they are typically much slower than the equivalent application running locally on a mobile device. Furthermore, the constant use of wireless transmissions can significantly shorten battery time and in many cases, the extensive network connection time that is required is very expensive.

2.4 Occasionally Connected Smart Client ApplicationsAn occasionally connected smart client application uses a local application together with a local database. No network connection is needed for the user to access information. The local application is designed to retrieve requested information from the local database on the device. The data in the local database is kept up to date using synchronization.

Page 3: A Study on Mobile-Application Database Using FireDac

2.1.3 Advantages: There are many advantages to the smart client model. First of all, when a user needs data it is instantly available, without waiting for relatively slow network transmission. Furthermore, wireless network connectivity is not required to access the data, enabling the application to be used anywhere at any time. Because the application is running locally on the device, it can be designed to take advantage of all the capabilities of the device, ensuring a rich user experience.

2.2.2 Disadvantages: The design and development of an occasionally connected smart client application may be more complex than an online application. In addition, you need to consider how to deploy the application, as well as how to maintain it.

3. MOBILE APPLICATION DESIGN INTERFACEA mobile application will normally be structured as a multilayered application consisting of presentation, business, and data layers. When developing a mobile application, you may choose to develop a thin Web-based client or a rich client. If you are building a rich client, the business and data services layers are likely to be located on the device itself. If you are building a thin client, all of the layers will be located on the server. Figure 1 illustrates common rich client mobile application architecture with components grouped by areas of concern.

Figure 2. The typical structure of a mobile application

A mobile application generally contains user interface components in the presentation layer, and perhaps may include presentation logic components. The business layer, if it exists, will usually contain business logic components, any business workflow and business entity components that are required by the application, and, optionally, a façade. The data layer will usually include data access and service agent components. In order to minimize the footprint on the device, mobile

applications generally use less rigid layering approaches and fewer discrete components.

3.1 Using Interbase FireDac (iOS & Android) Tip: Following this tutorial requires a license for IBToGo or IBLite:

If you purchased one of the following RAD Studio versions, you have received in Email a key for an unlimited development and deployment license for IBLite:

RAD Studio XE5 Professional or higher

Delphi XE5 Professional with Mobile or higher

If you are a trial user, your installation includes a trial license for IBToGo. You can test InterBase on iOS and Android by selecting your test license during the deployment step, as described in this tutorial. The trial licenses are installed with your trial product, in PublicInterBaseXE3Path

Note: On Android devices, InterBase ToGo apps require specific Uses Permissions to be set, specifically:

Read external storage (the database is placed in the external memory)

Write external storage (the database is placed in the external memory)

Internet (you need to connect with a remote server)

Figure 3. Database Demo for iOS and Android

This tutorial describes the basic steps to browse data managed by InterBase ToGo on your iOS and Android devices through the FireDAC framework.

Note: You can use FireDAC, dbExpress, and Interbase Express (IBX) components to build Interbase ToGo applications. For a detailed discussion on Interbase Express components usage in a Delphi application, read the Getting Started with InterBase Express article. For this tutorial, we will connect to Interbase ToGo using dbExpress framework.

Page 4: A Study on Mobile-Application Database Using FireDac

3.2 Using FireDAC to Connect to the Database FireDAC is a unique set of Universal Data Access Components for developing cross-platform database applications for Delphi and C++Builder. With its powerful common architecture, FireDAC enables native high-speed direct access from Delphi to InterBase, SQLite, MySQL, SQL Server, Oracle, PostgreSQL, IBM DB2, SQL Anywhere, Access, Firebird, Informix, and more.

For the mobile platforms, FireDAC supports InterBase ToGo as well as SQLite. These database products can run on iOS and Android devices.

For other databases, such as Oracle, you need to have at least a client library. On Windows platforms, the client library is provided as a DLL to connect to. Therefore, you need to develop applications using middle-tier technologies such as DataSnap to connect to these database products from a mobile device.

Another tutorial discusses how to connect to Enterprise Database without using a client library on a mobile device; see Mobile Tutorial: Connecting to an Enterprise Database from a Mobile Client (iOS and Android).

3.2.1. FireDac Benefits

FireDAC is the fruit of 10 years of experience in developing real-world database applications.

FireDAC enables the developer to concentrate on developing the application, not on the complexities of database interaction.

FireDAC provides a modern feature-rich set of components to address all major RDBMS environments.

FireDAC uses one set of components to address all supported RDBMS types.

FireDAC reduces the Total Cost of Ownership by providing:

o Less initial cost, compared to separate expensive libraries.

o Less time required to learn and become familiar with the unique powerful libraries.

o Straight-ahead application design and development when targeting different databases.

3.3 Design and Set-Up the User Interface

This tutorial uses TListView and TPanel components as the UI elements.

To set up a ListView and a Panel component, use the following steps:

To create an HD FireMonkey Mobile Application, select either of the following:

File > New > FireMonkey Mobile Application - Delphi > Blank Application

File > New > FireMonkey Mobile Application - C++Builder > Blank Application

Drop a TListView component on the form.

In the Object Inspector, set the following properties of the ListView:

Set the Align property to Client, so that the ListView component uses the entire form.

Set the ItemAppearance to ListItemRightDetail.

Set the SearchVisible to true.

Add a TPanel component to the form, and set the following properties in the Object Inspector:

Set the Align property for the TPanel component to Top.

Add a TLabel component to the Panel, and set the following properties in the Object Inspector:

Set the Align property for the TLabel component to Client.

Set the StyleLookup property to listboxitemlabel.

Set the HorzAlign property in TextSettings to Center.

Set the Text property to DB DEMO.

3.4 Connecting to the DataFollowing are the basic steps to connect to data in a database using FireDAC:

3.4.1On the Tool Palette, double-click the TFDConnection component

Figure 4. Tool Palette

3.4.2 Right-click the TFDConnection component and choose Connection Editor. 3.4.3 In the FireDAC Connection Editor, set the following parameters of the TFDConnection:

Set the Driver ID property to IB.

Set the Database parameter to:

C:\Users\Public\Documents\Embarcadero\Studio\14.0\Samples\Data\dbdemos.gdb (location of the database) and click Open in the File Open dialog box.

Set the User_name parameter to sysdba.

Set the Password parameter to masterkey.

Page 5: A Study on Mobile-Application Database Using FireDac

Figure 5 Connection Editor

3.4.4 Click the Test button to test the connection.

3.4.5 Click OK to close the Connection Editor.

3.4.6 In the Object Inspector, set the following properties of TFDConnection:

3.4.7Set the LoginPrompt property to False, so that the user is not prompted for a login.

3.4.8Set the Connected property to True.

Note: If you get an error ("unavailable database") in the development environment, this means you do not have a current license for InterBase. The license of InterBase Developer Edition is included as part of the product for some product editions. For more information, see Troubleshooting.

3.4.9 Add a TFDQuery component to the form.

3.4.10 Right-click the TFDQuery component and choose Query Editor.

3.4.11Write in the SQL Command Text editor select COMMON_NAME, SPECIES_NAME from BIOLIFE order by COMMON_NAME.

3.4.12Click the Execute button to see the command results.

Figure 6. Query Editor

3.4.13 Click OK to close the Query Editor.

3.4.14 In the Object Inspector, set the Active property of the TFDQuery component to True. 3.4.15 Open the LiveBindings Designer and connect the data and the user interface as follows:

3.4.15Click COMMON_NAME in FDQuery1, and drag the mouse cursor to Item.Text in ListView1.

Figure 7. LiveBindings Designer

3.4.17 At this point, TBindSourceDB and TBindingsList components were added to the form. 3.4.18 Click SPECIES_NAME in BindSourceDB1, and drag the mouse cursor to Item.Detail in ListView1.

Figure 8. Item Bindings Bindsource Display

3.4.20Add a TFDPhysIBDriverLink component to the form.

3.4.21Add a TFDGUIxWaitCursor component to the form.

Note: The Preparing a FireDAC Application for Run Time topic explains the use of the TFDGUIxWaitCursor and TFDPhysIBDriverLink components in a FireDAC application.

3.5 Deploying your Application to MobileUp to this point, you have used InterBase on your desktop. This means that the actual database is located at your local hard disk drive (for example, C:\Users\Public\Documents\Embarcadero\Studio\14.0\Samples\Data\dbdemos.gdb). On the mobile Device, the application is sand-boxed, and typically you can only read and write data that is located in the Documents folder (for iOS device) and internal storage (for Android device) under your application folder.

Page 6: A Study on Mobile-Application Database Using FireDac

To connect to a local database on mobile, you need to perform the following actions:

Deploy the database to the mobile device.

Change the configuration (to connect to the database file) to a local file under the Documents folder (for iOS device) or internal storage (for Android device).

3.6 Deploying InterBase ToGo and the Database File to Mobile To execute your application on mobile, you need to deploy the following files:

Interbase ToGo

The database file (dbdemos.gdb)

3.5.1.1Open the Deployment Manager by selecting Project > Deployment.

3.5.1.2Select All-Configurations - iOS Device platform or All-Configurations - Android platform from the drop-down list of target platforms at the top of the Deployment Manager.

3.5.1.3Select Add Featured Files ( ):

Figure 9. Add Feature Item

3.5.1.4Select the following database modules, and then click OK to close the Featured Files dialog box:

2.1.3.1 InterBase ToGo. You need to select the license to be used when deploying the application on the device.

o The Tip at the beginning of this tutorial describes how to activate an InterBase license.

o The suggested names for the license files available are listed in the Featured Files dialog, under the following name pattern: reg_*.txt.

2.4.23 As you can see in the image below, the reg_ibtogo.txt license file is selected for this tutorial.

1.1.1 You might have received from Embarcadero a license file for IBToGo or IBLite that has a pattern of reg_nnnnnnn.txt, where nnnnnnn is a generated number:

If you have saved that file over reg_ibtogo.txt or reg_iblite.txt in the location below (for example, C:\Users\Public\Documents\Embarcadero\InterBase\redist\InterBaseXE3), you can just select the desired license.

If you have saved the file with its original name, then select Add Files (shown in the next step) and include the license file in the list of files that need to be deployed with the application.

Figure 10. Featured Files

1.1.2 Select Add Files and select the database file (for example, C:\Users\Public\Documents\Embarcadero\Studio\14.0\

Samples\Data\dbdemos.gdb).

Figure 11. Add File Data

2.5.26 Select dbdemos.gdb and change Remote Path to StartUp\Documents\ (for iOS platform) or assets\internal\ (for Android platform).

Figure 12. RemotePath on iOS device platform

2.5.27 Select the Platforms column (double-click the ellipsis [...] in the row for dbdemos.gdb):

Ensure that iOS Simulator and iOS Device or Android are present for dbdemos.gdb.

Remove Win32 from the list if it is present (you do not have to copy database files to the Win32 platform).

2.1.4 Select All-Configurations - iOS Device platform or All-Configurations - Android platform, and make sure dbdemos.gdb is set to be deployed to StartUp\Documents\ or assets\internal.

As you just configured, when you run the app on the mobile device, the database file (dbdemos.gdb) is to be deployed to the Documents folder (for iOS platform) or internal storage (for Android platform) in the sandbox area of your mobile app.

Page 7: A Study on Mobile-Application Database Using FireDac

Delphi:

procedure TForm1.FDConnection1BeforeConnect(Sender: TObject);begin {$IF DEFINED(iOS) or DEFINED(ANDROID)} FDConnection1.Params.Values['Database'] := TPath.Combine(TPath.GetDocumentsPath, 'dbdemos.gdb'); {$ENDIF}end;

The TPath record is declared in System.IOUtils unit, so you need to add System.IOUtils in the uses clause.

C++:

void __fastcall TForm1::SQLConnection1BeforeConnect(TObject *Sender){ #if ((defined(__arm__) && defined(__APPLE__)) || defined(__ANDROID__)) FDConnection1->Params->Values["Database"] = System::Ioutils::TPath::Combine(System::Ioutils::TPath::GetDocumentsPath(), "dbdemos.gdb"); #endif}

You need to add #include <System.IOUtils.hpp>.

3.7 Run Your Application on a Simulator or on a Mobile Device Now your application is ready to run. You should be able to browse data just as you can in the (IDE) Integrated Development Environment. You can narrow down the list using the Search Box.

Figure 13. Database Demo

3.8 Troubleshooting 2.1.5 InterBase License Issues

If you get an error ("unavailabale database") when you connect to the database in the development environment, this means you forgot to deploy the Interbase ToGo license.

To execute your application on mobile, deploy the reg_ibtogo.txt or reg_iblite.txt license files.

The license files are located in PublicInterBaseXE3Path directory.

2.1.6 Exception Handling Issues

If your application raises an exception without having proper

exception handling code, your mobile app simply crashes (disappears) at run time.

If you encounter a crash, you might want to connect manually to the database while you troubleshoot the issue using the following steps:

1. Select the FDConnection1 component, and change the Connected property to False.

2. Drop a button on the form, and create the following event handler to manually connect to the database:

Delphi:

procedure TForm1.Button1Click(Sender: TObject);begin try FDConnection1.Connected := True; FDQuery1.Active := True; except on e: Exception do begin ShowMessage(e.Message); end; end;end;

C++:

void __fastcall TForm1::Button1Click(TObject *Sender) { try { FDConnection1->Connected = true; FDQuery1->Active = true; } catch(Exception &e) { ShowMessage(e.Message); }}

Page 8: A Study on Mobile-Application Database Using FireDac

2.1.7 Typical Errors and Resolutions

Following are typical errors that you might encounter when you connect to the database, and suggestions for resolving the issues:

Figure 14. Typical Error

3.9 Mobile Tutorial: Using SQLite (iOS and Android)Before starting this tutorial, you should read and perform the following tutorial session:

Mobile Tutorial: Using LiveBindings to Populate a ListView (iOS and Android)

This tutorial describes the basic steps to use SQLite as a local data storage on your mobile device through the SQLite framework.

Figre 14. Using SQLite

FireDAC is a unique set of Universal Data Access Components for developing cross-platform database applications for Delphi and C++Builder. With its powerful common architecture, FireDAC enables native high-speed direct access from Delphi to InterBase, SQLite, MySQL, SQL Server, Oracle, PostgreSQL, IBM DB2, SQL Anywhere, Access, Firebird, Informix, and more.

For the mobile platforms, FireDAC supports InterBase ToGo as well as SQLite. These database products can run on iOS and Android devices.

For other databases, such as Oracle, you need to have at least a client library. On Windows platforms, the client library is provided as a DLL to connect to. Therefore, you need to develop applications using middle-tier technologies such as DataSnap REST to connect to these database products from a mobile device.

Another tutorial discusses how to connect to Enterprise Database without using a client library on a mobile device; see Mobile Tutorial: Connecting to an Enterprise Database from a Mobile Client (iOS and Android).

3.10 Creating the Database using FireDAC in SQLite framework First, you need to create a SQLite database file on your Windows development platform. Use the following steps, so that you can use the FireMonkey Mobile Form Designer to design the user interface of your Mobile App.

3.10.1 To create an HD FireMonkey Mobile Application, select:

o For Delphi: File > New > FireMonkey Mobile Application - Delphi > Blank Application

o For C++: File > New > FireMonkey Mobile Application - C++Builder > Blank Application

3.10.2 On the Tool Palette, double-click the TFDConnection component.

Figure 15. Tool Palette for SQLite

3.10.3 Right click the TFDConnection component and choose Connection Editor. 3.10.4 In the FireDAC Connection Editor, set the following parameters of the TFDConnection:

Set the Driver ID property to SQLite.

Set the Database parameter to:

C:\Users\Public\Documents\Embarcadero\Studio\14.0\Samples\Data\shoplist.s3db (location of the database) and click Open in the File Open dialog box.

Page 9: A Study on Mobile-Application Database Using FireDac

Note: You can set the above Database parameter even if shoplist.s3db does not exist. (To display Employees.s3db or other *.s3db files in the Open dialog, set the All Files (*.*) option.)

Set the LockingMode parameter to normal.

Figure 16. FireDac Connection Editor in SQLite

Click the Test button to test the connection.

Click OK to close the Connection Editor.

3.10.5 In the Object Inspector, set the following properties of TFDConnection:

Set the LoginPrompt property to False, so that the user is not prompted for a login.

Set the Connected property to True.

3.10.6 On the Tool Palette, double-click the TFDQuery component. 3.10.7 In the Object Inspector, set the following properties of TFDQuery:

Set the Name property to FDQueryCreateTable.

Set the SQL property as follows:

CREATE TABLE IF NOT EXISTS Item (ShopItem TEXT NOT NULL)

3.10.7 Right click the FDQueryCreateTable and choose Execute.

3.11 Design and Set Up the User Interface This tutorial uses one TListView component as the UI element.

To set up a ListView component and other UI elements, use the following steps:

3.11.1 Drop a TToolBar on the form.

3.11.2 Drop a TButton on the ToolBar component and set the following properties in the Object Inspector:

o Set the Name property to ButtonAdd.

o Set the StyleLookup to addtoolbutton.

3.11.3 Drop a TButton on the ToolBar component and set the following properties in the Object Inspector:

o Set the Name property to ButtonDelete.

o Set the StyleLookup to deletetoolbutton.

o Set the Text to Delete.

o Set the Visible property to False.

3.11.4 Drop a TLabel on the ToolBar component and set the following properties in the Object Inspector:

o Set the Align to Client.

o Set the StyleLookup to toollabel.

o Set the Text to Shopping List.

o Expand the TTextSettings node and set the HorzAlign property to Center.

3.11.5 Drop a TListView component on the form and set the following properties in the Object Inspector:

o Set the Align property to Client, so that the ListView component uses the entire form.

Figure 17. Tablelist View for FireDac SQLite

Page 10: A Study on Mobile-Application Database Using FireDac

3.12 Displaying ShopItem in the ListView The following step displays the text of ShopItem in the TListView component.

3.12.1 In the LiveBindings Designer select ShopItem in the BindSourceDB1 component and drag ShopItem to Item.Text in ListView1.

Figure 18 Livebindings Designer Layer

Following these steps connects the app's user interface with data on a SQLite database. If you used a table with existing data for this tutorial, now you should see actual data within the Form Designer.

3.13 Creating the Event Handler to Make the Delete Button Visible When the User Selects an Item from the List The Visible property for the Delete button is set to False. Therefore, by default, the end user does not see this button. You can make it visible when the user selects an item on the list, as follows:

Select ListView1 and define the following event handler for the OnItemClick event.

Delphi:

procedure TForm1.ListView1ItemClick(const Sender: TObject; const AItem: TListViewItem);begin ButtonDelete.Visible := ListView1.Selected <> nil;end;

C++:

void __fastcall TForm1::ListView1ItemClick(const TObject *Sender,

const TListViewItem *AItem) {ButtonDelete->Visible = (ListView1->Selected !=

NULL);}

3.14 Creating the Event Handler for the Add Button to Add an Entry to the List The next step is adding a feature to this application for adding an item to the shopping list.

3.14.1 Drop a TFDQuery component on the form.

3.14.2 Set the following properties in the Object Inspector:

o Set the Name property to FDQueryInsert.

o Set the SQL property as follows:

o

INSERT INTO ITEM (ShopItem) VALUES (:ShopItem)

o Select the Expand (...) button on the Params property.

o Select the ShopItem parameter and set DataType to ftString: .

Figure 19. ShoppingList Overview Display

Page 11: A Study on Mobile-Application Database Using FireDac

Figure 20. Adding Objects in SQLite Using FireDac

3.14.3 In the Structure View, right-click the ButtonAdd component and select Control > Bring to Front. This brings the button to the visual front of the active form. 3.14.4 In the Form Designer, double-click the ButtonAdd component. Add the following code to this event handler:

Delphi: procedure TForm1.ButtonAddClick(Sender: TObject);var TaskName: String;begin try if InputQuery('Enter New Item', 'Name', TaskName) and (TaskName.Trim <> '') then begin FDQueryInsert.ParamByName('ShopItem').AsString := TaskName; FDQueryInsert.ExecSQL(); FDQuery1.Close; FDQuery1.Open; ButtonDelete.Visible := ListView1.Selected <> nil; end; except on e: Exception do begin ShowMessage(e.Message); end; end;end;

C++: void __fastcall TForm1::ButtonAddClick(TObject *Sender) {

String TaskName;try {

if ((InputQuery("Enter New Item", "Name", TaskName)) &&

(!(Trim(TaskName) == ""))) {

FDQueryInsert->ParamByName("ShopItem")->AsString = TaskName;

FDQueryInsert->ExecSQL();

FDQuery1->Close();

FDQuery1->Open();

ButtonDelete->Visible = (ListView1->Selected != NULL);

}}catch (Exception &e) {

ShowMessage(e.Message);}

}

Figure 21. Entry Level in SQlite

The InputQuery function shows a dialog box asking the end user to enter text. This function returns true when the user selects OK, so that you can add data to the database only when the user selects OK and the text contains some data.

4 Statistics Overview on FireDac and SQLite

Figure 22. FireDac Statistics

This statistics overview shows the performance rating through the overall and different information of firedac.

Page 12: A Study on Mobile-Application Database Using FireDac

Figure 23.FireDac Charts Statistics

Figure 24. Chart SQLite Statistics

# Name Year Tier Battles

With other

database

Winrate

1 FireDac 2014 8 level standing

1290 users

51.3%

2 SQLite 2007 5 level standing

869

users

45.3%

3 DBExpress

2003 6 level standing

760

users

43.9%

4 Oracle 2002 5 level standing

1639

users

51.49%

5 AMX AC Mle. 1948

2006 8 level standing

766

users

43.60%

6 AMX 50 100

2005 8 level standing

645

users

45.60%

7 AMX 120 2005 8 level standing

510

users

46.27%

Table 1. Statistics for different Mobile Database Application

Based on our research on this table provides the different stat

4.1 Features of FireDac and SQLiteFireDac and SQLite Mobile Database device design and development is unique due to the constrained and different Features on the Following

FireDac Consider the device-specific capabilities that you can use to enhance your application functionality such as accelerometers, graphics processing units in addition this is a private database and can be bought through the net, and also when it comes to security this is best for its maintenance.

FireDac also Consider using programming shortcuts as opposed to following pure programming practices that can inflate code size and memory consumption. For compatibility of different mobile databases

SQLite is an open source database Application and its free an can be downloaded through the net and it Considers limited memory resources and optimize your application to use the minimum amount of memory. When memory is low, the system may release cached intermediate language (IL) code to reduce its own memory footprint, return to interpreted mode, and thus slow overall execution.

Caching in FireDac the performance and responsiveness of the database application, and to support operation has better network connection. Caching can optimize reference data lookups, it avoid s network round trips, and prevent unnecessarily duplicated processing.

Communication in FireDac Device communication includes better wireless communication (over the air) and wired communication with a host computer.

Configuration Management SQLite appropriate format for configuration information. Consider a binary format over XML to minimize memory use. Consider using compression library routines to reduce the memory requirements for storing configuration and state information. Ensure that you encrypt sensitive data stored in configuration files.

Data Access on FireDac and SQLite has a constrained reliable network connections and the hardware constraints of the device itself. Through designing data access, consider how low bandwidth, high latency, and intermittent connectivity will affect your design. Consider the following guidelines when designing data access:

Note: This is based on the international references in FireDac forums.

5. CONCLUSIONBased on our conclusion towards the mobile database application FireDac based on our statistics and results on the mobile database application that provides a compatibility through different databases that interconnects with the latest mobile databases it also provides better services and security based on the development of its database ancestors through the mobile application.

Based on our research we have concluded that FireDac has the better performance, design and architecture compared to other

Page 13: A Study on Mobile-Application Database Using FireDac

mobile database applications in terms of interface, connectivity, manageability and configuration.

6. RECOMMENDATIONFireDAC is a unique set of Universal Data Access Components for developing cross-platform database applications for Delphi, C++Builder and FreePascal. With its powerful common architecture, FireDAC enables native high-speed direct access from Delphi to InterBase, SQLite, MySQL, SQL Server, Oracle, PostgreSQL, IBM DB2, SQL Anywhere, Access, Firebird, Informix and more.

We discovered that a Delphi developer from a few versions back was considering upgrading to XE5, but he wanted to know if FireDAC was recommended for database access.

6.1 Working on some data driven Delphi applications when the drill was you always bought a 3rd party database access library. There are lots of great database access libraries to choose from, which is one of the great things about Delphi: all the technology partners!

6.2 FireDAC is a universal data access library: you use the same components to connect to a huge variety of databases. The usage pattern is similar to the BDE, and it is fully bidirectional. It also has a large collection of specialized features for dealing with specific databases, and local, in memory data.

6.3 If you are still on the BDE, check out the FireDAC migration guide or any of the other great FireDAC documentation. Cary Jensen just did a fabulous webinar on FireDAC including a fabulous 70 page whitepaper.

7. REFERENCES

[1] Marco 2013. FireDac in Delphi xe5. http://blog.marcocantu.com/blog/firedac_xe5.html

[2] Jim McKeeth 2013. FireDac is the Recommended Database Access Library http://delphi.org/2013/12/firedac-is-recommended/

[3] Embarcadero Technologies 2014. FireDac. https://www.embarcadero.com/products/rad-studio/firedac-faq

[4] #FireDac : https://twitter.com/hashtag/firedac

[5] Rad Studio 2014. FireDac http://docwiki.embarcadero.com/RADStudio/XE5/en/FireDAC

[6] FireDac and SQL Anywhere: http://sqlanywhere-forum.sap.com/questions/21472/firedac-and-sql-anywhere