You are on page 1of 13

A Study on Mobile-Application Database using FireDac

Adina, Jayson Jenrie R.


#35 Tabora Street, Trancoville,
Baguio City, Benguet
074-443-81-33, 2600
jayzon0102@yahoo.com
Chacapna, Teodorico D.
Abatan, Bauko
Mountain Province
09467676688l, 2621
rico_mpspc@yahoo.com
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
obile!"pplication #atabase using $ire#ac. %e will focus on
interface, connection, benefits, design and set!up, and
deployment of application to mobile devices.
oreover we will provide a step by step procedure or Tutorial in
installing the $ire#ac and &'(ite )ompatibility in obile
"pplication for accessing the library through the database.
Keywords
obile "pplication* %eb +ased "pplication* #atabase obile
,latform, $ire#ac, #+E-press, &'(ite, #atabase ,rocedures,
Tutorial, #elphi, )..
1. !TR"D#CT"!
Increasingly, organizations now a days are looking for new ways
to improve their productivity and competitiveness. /ne area is
through mobile computing.
" well!designed mobile application can enable an organization's
to be more productive and competitive by deliver improved
customer service while reducing operating costs. 0owever,
mobile applications re1uire innovative approaches to employing
critical business applications and data. "ny data or application
that is used must integrate with and leverage an organization's
e-isting application and database infrastructure.
There are two primary models for mobile applications2 online
applications and occasionally connected smart client
applications. /nline applications re1uire a network connection to
a backend enterprise data source, and are usually browser!based.
/ccasionally connected smart client applications are
characterized by a local data store and local application, and do
not re1uire 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 Ai$ o% Researc&
In this paper, the researchers will discuss the comparison of the
obile "pplication #atabases using $ire#ac. %e will focus on
interface, connection, benefits, design and set!up, and
deployment of application to mobile.
1.' Mobile Database
" mobile database is either a stationary database that can be
connected to by a $obile co$puting device 3e.g., s$artp&ones,
tablets and (DAs4 over a $obile networ), 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.
any applications re1uire the ability to download information
from an information repository and operate on this information
even when out of range or disconnected. "n e-ample of this is
your contacts and calendar on the phone. In this scenario, a user
would re1uire 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 client5
server systems of today. obile databases are not used solely for
the revision of company contacts and calendars, but used in a
number of industries.
'. R*S*ARC+ M*T+"D","-.
6ecord 6etrieve "nalyze )reate
$igure 7. )ollecting #ata 6esearch ethodology
$or most research pro8ects the data collection phase feels like the
most important part. 0owever, you should avoid 8umping straight
into this phase until you have ade1uately defined your research
problem, and the e-tent and limitations of your research. If you
are too hasty you risk collecting data that you will not be able to
use.
)onsider how you are going to store and retrieve your data. 9ou
should set up a system that allows you to2
record data accurately as you collect it*
retrieve data 1uickly 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 inde-es and cross!referenced
e-ercise books, through electronic tools like spreadsheets,
databases and bibliographic software, to discipline!specific tools.
9ou should talk about how you plan to store your data with your
supervisor, an information librarian, or a study adviser in the
(earning #evelopment. "s 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 inde- cards, in a dedicated notebook, or
in an electronic file. 9ou 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.
'.1 Mobile Database Application
Consideration
obile users must be able to work without a network connection
due to poor or even non!e-istent connections. " cache could be
maintained to hold recently accessed data and transactions so
that they are not lost due to connection failure. <sers might not
re1uire access to truly live data, only recently modified data, and
uploading of changing might be deferred until reconnected.
+andwidth must be conserved 3a common re1uirement on
wireless networks that charge per megabyte or data transferred4.
obile computing devices tend to have slower ),<s and limited
battery life. <sers with multiple devices 3e.g. smartphone and
tablet4 need to synchronize their devices to a centralized data
store. This may re1uire 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 8ust the last
update is kept, but also supports =merge= of variants. <sers may
change location geographically and on the network. <sually
dealing with this is left to the operating system, which is
responsible for maintaining the wireless network connection.
'.1 Best (ractices o% Mobile Database
Application
>"uthor?
@.A.7 )hoose 9our obile #atabase and #ata &ynchronization
Infrastructure
@.A.@ Tutorial on obile #atabase and &ynchronization
Infrastructure
@.A.B "nalyze on the #atabase "pplication #evelopment
"pproach.
'./ "nline Application Database
"n online application does not store any data or application logic
on the mobile device. Therefore, when the user re1uires access to
the application and data, a network connection is re1uired.
Typically with mobile devices, this network connection is
wireless, either %i$i or %ide "rea Cetwork 3%"C4. "ll data and
applications are transmitted through this wireless network
connection only when re1uested by the user.
@.7.7 Ad0antages2 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. %hen data is re1uired, it is
retrieved directly from the enterprise's back!end data store.
+ecause 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. &ecurity is seemingly
easier to manage because no data is actually stored on the mobile
device.
@.7.@ Disad0antages2 There are some significant
disadvantages to the online model that primarily occur in two
areas2 user e-pectations and network communications. " user's
primary e-pectation is that the application and data will always
be available. +ut 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. +ecause online applications re1uire
communication over a wireless network, they are typically much
slower than the e1uivalent application running locally on a
mobile device. $urthermore, the constant use of wireless
transmissions can significantly shorten battery time and in many
cases, the e-tensive network connection time that is re1uired is
very e-pensive.
'.1 "ccasionally Connected S$art Client
Applications
"n occasionally connected smart client application uses a local
application together with a local database. Co network
connection is needed for the user to access information. The local
application is designed to retrieve re1uested information from the
local database on the device. The data in the local database is
kept up to date using synchronization.
@.7.B Ad0antages2 There are many advantages to the smart
client model. $irst of all, when a user needs data it is instantly
available, without waiting for relatively slow network
transmission. $urthermore, wireless network connectivity is not
re1uired to access the data, enabling the application to be used
anywhere at any time. +ecause 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 e-perience.
@.@.@ Disad0antages2 The design and development of an
occasionally connected smart client application may be more
comple- than an online application. In addition, you need to
consider how to deploy the application, as well as how to
maintain it.
/. M"B,* A((,CAT"! D*S-!
!T*RFAC*
" mobile application will normally be structured as a
multilayered application consisting of presentation, business, and
data layers. %hen developing a mobile application, you may
choose to develop a thin %eb!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. $igure 7
illustrates common rich client mobile application architecture
with components grouped by areas of concern.
$igure @. The typical structure of a mobile application
" mobile application generally contains user interface
components in the presentation layer, and perhaps may include
presentation logic components. The business layer, if it e-ists,
will usually contain business logic components, any business
workflow and business entity components that are re1uired by
the application, and, optionally, a faDade. 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.
/.1 #sing nterbase FireDac 2i"S 3 Android4
Tip2 $ollowing this tutorial re1uires a license for I+ToEo or
I+(ite2
If you purchased one of the following 6"# &tudio versions,
you have received in Email a key for an unlimited development
and deployment license for I+(ite2
6"# &tudio FEG ,rofessional or higher
#elphi FEG ,rofessional with obile or higher
If you are a trial user, your installation includes a trial
license for I+ToEo. 9ou can test Inter+ase on i/& and "ndroid
by selecting your test license during the deployment step, as
described in this tutorial. The trial licenses are installed with
your trial product, in ,ublicInter+aseFEB,ath
Cote2 /n "ndroid devices, Inter+ase ToEo apps re1uire
specific <ses ,ermissions to be set, specifically2
6ead e-ternal storage 3the database is placed in the e-ternal
memory4
%rite e-ternal storage 3the database is placed in the
e-ternal memory4
Internet 3you need to connect with a remote server4
$igure B. #atabase #emo for i/& and "ndroid
This tutorial describes the basic steps to browse data managed by
Inter+ase ToEo on your i/& and "ndroid devices through the
$ire#") framework.
!ote5 9ou can use $ire#"), dbE-press, and Interbase E-press
3I+F4 components to build nterbase To-o applications. $or a
detailed discussion on Interbase E-press components usage in a
#elphi application, read the Eetting &tarted with Inter+ase
E-press article. $or this tutorial, we will connect to nterbase
To-o using dbE-press framework.
/.' #sing FireDAC to Connect to t&e Database
$ire#") is a uni1ue set of <niversal #ata "ccess )omponents
for developing cross!platform database applications for #elphi
and )..+uilder. %ith its powerful common architecture,
$ire#") enables native high!speed direct access from #elphi to
Inter+ase, &'(ite, y&'(, &'( &erver, /racle, ,ostgre&'(,
I+ #+@, &'( "nywhere, "ccess, $irebird, Informi-, and more.
$or the mobile platforms, $ire#") supports Inter+ase ToEo as
well as &'(ite. These database products can run on i/& and
"ndroid devices.
$or other databases, such as /racle, you need to have at least a
client library. /n %indows platforms, the client library is
provided as a #(( to connect to. Therefore, you need to develop
applications using middle!tier technologies such as #ata&nap to
connect to these database products from a mobile device.
"nother tutorial discusses how to connect to Enterprise #atabase
without using a client library on a mobile device* see obile
Tutorial2 )onnecting to an Enterprise #atabase from a obile
)lient 3i/& and "ndroid4.
/.'.1. FireDac Bene%its
$ire#") is the fruit of 7A years of e-perience in
developing real!world database applications.
$ire#") enables the developer to concentrate on
developing the application, not on the comple-ities of
database interaction.
$ire#") provides a modern feature!rich set of
components to address all ma8or 6#+&
environments.
$ire#") uses one set of components to address all
supported 6#+& types.
$ire#") reduces the Total )ost of /wnership by
providing2
o (ess initial cost, compared to separate
e-pensive libraries.
o (ess time re1uired to learn and become
familiar with the uni1ue powerful libraries.
o &traight!ahead application design and
development when targeting different
databases.
/./ Design and Set-#p t&e #ser nter%ace
This tutorial uses T(istHiew and T,anel components as the <I
elements.
To set up a (istHiew and a ,anel component, use the following
steps2
To create an 0# $ireonkey obile "pplication, select either
of the following2
$ile I Cew I $ireonkey obile "pplication ! #elphi I
+lank "pplication
$ile I Cew I $ireonkey obile "pplication ! )..+uilder I
+lank "pplication
#rop a T(istHiew component on the form.
In the /b8ect Inspector, set the following properties of the
(istHiew2
&et the "lign property to )lient, so that the (istHiew
component uses the entire form.
&et the Item"ppearance to (istItem6ight#etail.
&et the &earchHisible to true.
"dd a T,anel component to the form, and set the following
properties in the /b8ect Inspector2
&et the "lign property for the T,anel component to Top.
"dd a T(abel component to the ,anel, and set the following
properties in the /b8ect Inspector2
&et the "lign property for the T(abel component to )lient.
&et the &tyle(ookup property to listbo-itemlabel.
&et the 0orz"lign property in Te-t&ettings to )enter.
&et the Te-t property to #+ #E/.
/.1 Connecting to t&e Data
$ollowing are the basic steps to connect to data in a database
using $ire#")2
B.J.7/n the Tool Palette, double!click the T$#)onnection
component
$igure J. Tool ,alette
B.J.@ 6ight!click the T$#)onnection component and choose
Connection *ditor.
B.J.B In the $ire#") )onnection Editor, set the following
parameters of the T$#)onnection2
&et the Driver ID property to B.
&et the Database parameter to2
)2K<sersK,ublicK#ocumentsKEmbarcaderoK&tudioK7J.AK&
amplesK#ataKdbdemos.gdb 3location of the database4
and click "pen in the $ile /pen dialog bo-.
&et the #ser6na$e parameter to sysdba.
&et the (assword parameter to $aster)ey.
$igure G )onnection Editor
B.J.J )lick the Test button to test the connection.
B.J.G )lick "K to close the )onnection Editor.
B.J.L In the /b8ect Inspector, set the following properties of
TFDConnection2
B.J.M&et the LoginPrompt property to $alse, so that the user is
not prompted for a login.
B.J.N&et the Connected property to True.
Cote2 If you get an error 3=unavailable database=4 in the
development environment, this means you do not have
a current license for Inter+ase. The license of Inter+ase
#eveloper Edition is included as part of the product for
some product editions. $or more information, see
Troubleshooting.
B.J.O "dd a T$#'uery component to the form.
B.J.7A 6ight!click the T$#'uery component and choose 'uery
Editor.
B.J.77%rite in the &'( )ommand Te-t editor select
COMMON_NAME, SPECIES_NAME rom !IOLI"E order #$
COMMON_NAME.
B.J.7@)lick the E-ecute button to see the command results.
$igure L. 'uery Editor
B.J.7B )lick "K to close the 'uery Editor.
B.J.7J In the /b8ect Inspector, set the "ctive property of the
T$#'uery component to True.
B.J.7G /pen the (ive+indings #esigner and connect the data and
the user interface as follows2
B.J.7G)lick C"MM"!6!AM* in $#'uery7, and drag the
mouse cursor to te$.Te7t in (istHiew7.
$igure M. (ive+indings #esigner
B.J.7M "t this point, T+ind&ource#+ and T+indings(ist
components were added to the form.
B.J.7N )lick S(*C*S6!AM* in +ind&ource#+7, and drag the
mouse cursor to te$.Detail in (istHiew7.
$igure N. Item +indings +indsource #isplay
B.J.@A"dd a TFD(&ysBDri0er,in) component to the form.
B.J.@7"dd a TFDGUIxWaitCursor component to the form.
!ote5 The ,reparing a $ire#") "pplication for 6un
Time topic e-plains the use of the
T$#E<I-%ait)ursor and T$#,hysI+#river(ink
components in a $ire#") application.
/.8 Deploying your Application to Mobile
<p to this point, you have used Inter+ase on your desktop. This
means that the actual database is located at your local hard disk
drive 3for e-ample,
)2K<sersK,ublicK#ocumentsKEmbarcaderoK&tudioK7J.AK&amplesK#
ataKdbdemos.gdb4. /n the mobile #evice, the application is sand!
bo-ed, and typically you can only read and write data that is
located in the Docu$ents folder 3for i/& device4 and internal
storage 3for "ndroid device4 under your application folder.
To connect to a local database on mobile, you need to perform the
following actions2
#eploy the database to the mobile device.
)hange the configuration 3to connect to the database
file4 to a local file under the Docu$ents folder 3for
i/& device4 or internal storage 3for "ndroid device4.
/.9 Deploying InterBase ToGo and the
Database File to Mobile
To e-ecute your application on mobile, you need to deploy the
following files2
Interbase ToEo
The database file 3dbdemos.gdb4
B.G.7.7/pen the Deplo$ment Manager by selecting (ro:ect ;
Deploy$ent.
B.G.7.@&elect "ll!)onfigurations ! i/& #evice platform or "ll!
)onfigurations ! "ndroid platform %ro$ t&e drop-down list o%
target plat%or$s at t&e top o% t&e Deploy$ent Manager.
B.G.7.B&elect Add Featured Files 2 45
$igure O. "dd $eature Item
B.G.7.J&elect the following database modules, and then click "K
to close the $eatured $iles dialog bo-2
%.&.'.& nterBase To-o. 9ou 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 Inter+ase
license.
o The suggested names for the license files
available are listed in the $eatured $iles
dialog, under the following name pattern2
reg6<.t7t.
@.J.@B "s you can see in the image below, the reg6ibtogo.t7t
license file is selected for this tutorial.
7.7.7 9ou might have received from Embarcadero a license
file for I+ToEo or I+(ite that has a pattern of reg6nnnnnnn.t7t,
where nnnnnnn is a generated number2
If you have saved that file over reg6ibtogo.t7t or
reg6iblite.t7t in the location below 3for e-ample,
)2K<sersK,ublicK#ocumentsKEmbarcaderoKInter+aseKred
istKInter+aseFEB4, you can 8ust select the desired
license.
If you have saved the file with its original name, then
select Add Files 3shown in the ne-t step4 and include
the license file in the list of files that need to be
deployed with the application.
$igure 7A. $eatured $iles
7.7.@ &elect Add Files and select the database file 3for
e-ample,
C()*sers)P+#lic)Doc+ments)Em#arcadero)St+dio)&,.-)Samples)
Data)d#demos.gd#..
$igure 77. "dd $ile #ata
@.G.@L &elect dbde$os.gdb and change Re$ote (at& to
Start#p=Docu$ents= 3for i/& platform4 or assets=internal= 3for
"ndroid platform4.
$igure 7@. 6emote,ath on i/& device platform
@.G.@M &elect the (lat%or$s column 3double!click the ellipsis
P...Q in the row for dbdemos.gdb42
Ensure that i"S Si$ulator and i"S De0ice or
Android are present for dbdemos.gdb.
6emove %inB@ from the list if it is present 3you do not
have to copy database files to the %inB@ platform4.
@.7.J &elect All-Con%igurations - i"S De0ice platform or
All-Con%igurations - Android plat%or$, and make sure
dbde$os.gdb is set to be deployed to Start#p=Docu$ents= or
assets=internal.
"s you 8ust configured, when you run the app on the mobile
device, the database file 3dbdemos.gdb4 is to be deployed to the
Docu$ents folder 3for i/& platform4 or internal storage 3for
"ndroid platform4 in the sandbo- area of your mobile app.
#elphi2
procedure T$orm7.$#)onnection7+efore)onnect3&ender2
T/b8ect4*
begin
RSI$ #E$ICE#3i/&4 or #E$ICE#3"C#6/I#4T
$#)onnection7.,arams.HaluesP'#atabase'Q 2U
T,ath.)ombine3T,ath.Eet#ocuments,ath, 'dbdemos.gdb'4*
RSEC#I$T
end*
The T,ath record is declared in Syste$."#tils unit, so you
need to add Syste$."#tils in the uses clause.
C>>5
void VVfastcall T$orm722&'()onnection7+efore)onnect3T/b8ect
W&ender4
R
Xif 33defined3VVarmVV4 YY defined3VV",,(EVV44 ZZ
defined3VV"C#6/I#VV44
$#)onnection7!I,arams!IHaluesP=#atabase=Q U

&ystem22Ioutils22T,ath22)ombine3&ystem22Ioutils22T,ath22Eet#ocu
ments,ath34, =dbdemos.gdb=4*
Xendif
T
9ou need to add ?include @Syste$."#tils.&pp;.
/.A Run .our Application on a Si$ulator or on
a Mobile De0ice
Cow your application is ready to run. 9ou should be able to
browse data 8ust as you can in the 3I#E4 Integrated #evelopment
Environment. 9ou can narrow down the list using the &earch
+o-.
$igure 7B. #atabase #emo
/.B Troubles&ooting
@.7.G Inter!ase License Iss+es
If you get an error 3=unavailabale database=4 when you connect to
the database in the development environment, this means you
forgot to deploy the Interbase ToEo license.
To e-ecute your application on mobile, deploy the
reg6ibtogo.t7t or reg6iblite.t7t license files.
The license files are located in
,ublicInter+aseFEB,ath directory.
@.7.L E/ception 0andling Iss+es
If your application raises an e-ception without having proper
e-ception handling code, your mobile app simply crashes
3disappears4 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 steps2
7. &elect the FDConnection1 component, and
change the )onnected property to False.
@. #rop a button on the form, and create the
following event handler to manually connect
to the database2
Delp&i5
procedure TForm1.Button1Click(Sender:
TObject);
begin
try
FDConnection1.Connected : True;
FD!uery1."cti#e : True;
e$cept
on e: %$ception do
begin
S&o'(e))*ge(e.(e))*ge);
end;
end;
end;
C>>5
#oid ++,*)tc*ll
TForm1::Button1Click(TObject -Sender) .
try .
FDConnection1/0Connected true;
FD!uery1/0"cti#e true;
1
c*tc&(%$ception 2e) .
S&o'(e))*ge(e.(e))*ge);
1
1
@.7.M T$pical Errors and 1esol+tions
$ollowing are typical errors that you might encounter when you
connect to the database, and suggestions for resolving the issues2
$igure 7J. Typical Error
/.C Mobile Tutorial5 #sing SD,ite 2i"S and
Android4
+efore starting this tutorial, you should read and perform the
following tutorial session2
Mobile Tutorial5 #sing ,i0eBindings to (opulate a
,istEiew 2i"S and Android4
This tutorial describes the basic steps to use &'(ite as a local
data storage on your mobile device through the &'(ite
framework.
$igre 7J. <sing &'(ite
$ire#") is a uni1ue set of #ni0ersal Data Access Co$ponents
for developing cross!platform database applications for #elphi
and )..+uilder. %ith its powerful common architecture,
$ire#") enables native high!speed direct access from #elphi to
Inter+ase, &'(ite, y&'(, &'( &erver, /racle, ,ostgre&'(,
I+ #+@, &'( "nywhere, "ccess, $irebird, Informi-, and more.
$or the mobile platforms, FireDAC supports
nterBase To-o as well as SD,ite. These database
products can run on i/& and "ndroid devices.
$or other databases, such as /racle, you need to have
at least a client library. /n %indows platforms, the
client library is provided as a #(( to connect to.
Therefore, you need to develop applications using
middle!tier technologies such as #ata&nap 6E&T to
connect to these database products from a mobile
device.
"nother tutorial discusses how to connect to Enterprise #atabase
without using a client library on a mobile device* see obile
Tutorial2 )onnecting to an Enterprise #atabase from a obile
)lient 3i/& and "ndroid4.
/.1F Creating t&e Database using FireDAC in
SD,ite %ra$ewor)
$irst, you need to create a &'(ite database file on your %indows
development platform. <se the following steps, so that you can
use the $ireonkey obile $orm #esigner to design the user
interface of your obile "pp.
B.7A.7 To create an 0# $ireonkey obile "pplication,
select2
o $or #elphi2 File ; !ew ; FireMon)ey
Mobile Application - Delp&i ; Blan)
Application
o $or )..2 File ; !ew ; FireMon)ey Mobile
Application - C>>Builder ; Blan)
Application
B.7A.@ /n the Tool Palette, double!click the TFDConnection
component.
$igure 7G. Tool ,alette for &'(ite
B.7A.B 6ight click the T$#)onnection component and choose
Connection *ditor.
B.7A.J In the $ire#") )onnection Editor, set the following
parameters of the T$#)onnection2
&et the #river I# property to SD,ite.
&et the Database parameter to2
)2K<sersK,ublicK#ocumentsKEmbarcaderoK&tudioK7J.AK&
amplesK#ataKshoplist.sBdb 3location of the database4
and click "pen in the $ile /pen dialog bo-.
!ote2 9ou can set the above Database parameter even
if s&oplist.s/db does not e-ist. 3To display
*$ployees.s/db or other <.s/db files in the /pen
dialog, set the All Files 2<.<4 option.4
&et the ,oc)ingMode parameter to nor$al.
$igure 7L. $ire#ac )onnection Editor in &'(ite
)lick the Test button to test the connection.
)lick "K to close the )onnection Editor.
B.7A.G In the /b8ect Inspector, set the following properties of
TFDConnection2
&et the ,ogin(ro$pt property to False, so that the
user is not prompted for a login.
&et the Connected property to True.
B.7A.L /n the Tool ,alette, double!click the TFDDuery
component.
B.7A.M In the /b8ect Inspector, set the following properties of
TFDDuery2
&et the Came property to FDDueryCreateTable.
&et the &'( property as follows2
)6E"TE T"+(E I$ C/T EFI&T& Item 3&hopItem
TEFT C/T C<((4
B.7A.M 6ight click the FDDueryCreateTable and choose
*7ecute.
/.11 Design and Set #p t&e #ser nter%ace
This tutorial uses one T(istHiew component as the <I element.
To set up a ,istEiew co$ponent and ot&er # ele$entsG use
t&e %ollowing steps5
B.77.7 #rop a TToolBar on the form.
B.77.@ #rop a TButton on the Tool+ar component and set
the following properties in the /b8ect Inspector2
o &et the Came property to ButtonAdd.
o &et the &tyle(ookup to addtoolbutton.
B.77.B #rop a TButton on the Tool+ar component and
set the following properties in the /b8ect Inspector2
o &et the Came property to ButtonDelete.
o &et the &tyle(ookup to deletetoolbutton.
o &et the Te-t to Delete.
o &et the Hisible property to False.
B.77.J #rop a T,abel on the Tool+ar component and
set the following properties in the /b8ect Inspector2
o &et the "lign to Client.
o &et the &tyle(ookup to toollabel.
o &et the Te-t to S&opping ,ist.
o E-pand the TTe-t&ettings node and set the
0orz"lign property to Center.
B.77.G #rop a T,istEiew component on the form and
set the following properties in the /b8ect Inspector2
o &et the "lign property to Client, so that the
(istHiew component uses the entire form.
$igure 7M. Tablelist Hiew for $ire#ac &'(ite
/.1' Displaying ShopItem in the Listie!
The following step displays the te-t of S&opte$ in the
T,istEiew component.
B.7@.7 In the (ive+indings #esigner select S&opte$ in the
BindSourceDB1 component and drag S&opte$ to
te$.Te7t in ,istEiew1.
$igure 7N (ivebindings #esigner (ayer
$ollowing these steps connects the app's user interface with data
on a &'(ite database. If you used a table with e-isting data for
this tutorial, now you should see actual data within the $orm
#esigner.
/.1/ Creating t&e *0ent +andler to Ma)e t&e
Delete Button Eisible H&en t&e #ser Selects an
te$ %ro$ t&e ,ist
The Hisible property for the Delete button is set to False.
Therefore, by default, the end user does not see this button. 9ou
can make it visible when the user selects an item on the list, as
follows2
&elect ,istEiew1 and define the following event
handler for the /nItem)lick event.
Delp&i5
procedure T$orm7.(istHiew7Item)lick3const &ender2 T/b8ect*
const "Item2 T(istHiewItem4*
begin
+utton#elete.Hisible 2U (istHiew7.&elected [I nil*
end*
C>>5
void VVfastcall T$orm722(istHiew7Item)lick3const T/b8ect
W&ender,
const T(istHiewItem W"Item4 R
+utton#elete!IHisible U 3(istHiew7!I&elected \U
C<((4*
T
/.11 Creating t&e *0ent +andler %or t&e Add
Button to Add an *ntry to t&e ,ist
The ne-t step is adding a feature to this application for adding an
item to the shopping list.
B.7J.7 #rop a T"D2+er$ component on the form.
B.7J.@ &et the following properties in the /b8ect Inspector2
o &et the Came property to $#'ueryInsert.
o &et the &'( property as follows2
o
IC&E6T ICT/ ITE 3&hopItem4 H"(<E& 32&hopItem4
o &elect the *7pand 3...4 button on the ,arams
property.
o &elect the S&opte$ parameter and set
#ataType to %tString2 .
$igure 7O. &hopping(ist /verview #isplay
$igure @A. "dding /b8ects in &'(ite <sing $ire#ac
B.7J.B In the &tructure Hiew, right!click the ButtonAdd
component and select Control ; Bring to Front. This brings the
button to the visual front of the active form.
B.7J.J In the $orm #esigner, double!click the ButtonAdd
component. "dd the following code to this event handler2
Delp&i5
procedure TForm1.Button"ddClick(Sender:
TObject);
#*r
T*)k3*me: String;
begin
try
i, 4nput!uery(5%nter 3e' 4tem56
53*me56 T*)k3*me) *nd (T*)k3*me.Trim 70
55) t&en
begin

FD!uery4n)ert.8*r*mBy3*me(5S&op4tem5).")
String : T*)k3*me;
FD!uery4n)ert.%$ecS!9();
FD!uery1.Clo)e;
FD!uery1.Open;
ButtonDelete.:i)ible :
9i)t:ie'1.Selected 70 nil;
end;
e$cept
on e: %$ception do
begin
S&o'(e))*ge(e.(e))*ge);
end;
end;
end;
C>>5
#oid ++,*)tc*ll
TForm1::Button"ddClick(TObject -Sender)
.
String T*)k3*me;
try .
i, ((4nput!uery(;%nter
3e' 4tem;6 ;3*me;6 T*)k3*me)) 22
(<(Trim(T*)k3*me)
;;))) .
FD!uery4n)ert/
08*r*mBy3*me(;S&op4tem;)/0")String
T*)k3*me;
FD!uery4n)ert/
0%$ecS!9();
FD!uery1/
0Clo)e();
FD!uery1/0Open();
ButtonDelete/
0:i)ible (9i)t:ie'1/0Selected <
3=99);
1
1
c*tc& (%$ception 2e) .
S&o'(e))*ge(e.(e))*ge);
1
1
$igure @7. Entry (evel in &'lite
The Input'uery function shows a dialog bo- asking the end user
to enter te-t. This function returns true when the user selects
"K, so that you can add data to the database only when the user
selects "K and the te-t contains some data.
1 Statistics "0er0iew on FireDac and SD,ite
$igure @@. $ire#ac &tatistics
This statistics overview shows the performance rating through
the overall and different information of firedac.
$igure @B.$ire#ac )harts &tatistics
$igure @J. )hart &'(ite &tatistics
X Came 9ear Tier +attles
%ith
other
database
%inrate
7 $ire#ac @A7J N level
standing
7@OA
users
G7.B]
@ &'(ite @AAM G level
standing
NLO
users
JG.B]
B #+E-pres
s
@AAB L level
standing
MLA
users
JB.O]
J /racle @AA@ G level
standing
7LBO
users
G7.JO]
G "F ")
le. 7OJN
@AAL N level
standing
MLL
users
JB.LA]
L "F GA
7AA
@AAG N level
standing
LJG
users
JG.LA]
M "F 7@A @AAG N level
standing
G7A
users
JL.@M]
Table 7. &tatistics for different obile #atabase "pplication
+ased on our research on this table provides the different stat
1.1 Features o% FireDac and SD,ite
$ire#ac and &'(ite obile #atabase device design and
development is uni1ue due to the constrained and different
$eatures on the $ollowing
$ire#ac )onsider 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.
$ire#ac also )onsider using programming shortcuts as
opposed to following pure programming practices that
can inflate code size and memory consumption. $or
compatibility of different mobile databases
&'(ite is an open source database "pplication and its
free an can be downloaded through the net and it
)onsiders limited memory resources and optimize your
application to use the minimum amount of memory.
%hen memory is low, the system may release cached
intermediate language 3I(4 code to reduce its own
memory footprint, return to interpreted mode, and thus
slow overall e-ecution.
Cac&ing in $ire#ac the performance and
responsiveness of the database application, and to
support operation has better network connection.
)aching can optimize reference data lookups, it avoid s
network round trips, and prevent unnecessarily
duplicated processing.
Co$$unication in $ire#ac #evice communication
includes better wireless communication 3over the air4
and wired communication with a host computer.
Con%iguration Manage$ent &'(ite appropriate
format for configuration information. )onsider a binary
format over F( to minimize memory use. )onsider
using compression library routines to reduce the
memory re1uirements for storing configuration and
state information. Ensure that you encrypt sensitive
data stored in configuration files.
Data Access on $ire#ac and &'(ite 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.
)onsider the following guidelines when designing data
access2
Cote2 This is based on the international references in $ire#ac
forums.
8. C"!C,#S"!
+ased on our conclusion towards the mobile database application
$ire#ac 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.
+ased on our research we have concluded that $ire#ac has the
better performance, design and architecture compared to other
mobile database applications in terms of interface, connectivity,
manageability and configuration.
9. R*C"MM*!DAT"!
$ire#") is a uni1ue set of #ni0ersal Data Access Co$ponents
for developing cross!platform database applications for #elphi,
)..+uilder and $ree,ascal. %ith its powerful common
architecture, $ire#") enables native high!speed direct access
from #elphi to Inter+ase, &'(ite, y&'(, &'( &erver, /racle,
,ostgre&'(, I+ #+@, &'( "nywhere, "ccess, $irebird,
Informi- and more.
%e discovered that a #elphi developer from a few versions back
was considering upgrading to FEG, but he wanted to know if
$ire#") was recommended for database access.
L.7 %orking on some data driven #elphi applications when the
drill was you always bought a Brd party database access library.
There are lots of great database access libraries to choose from,
which is one of the great things about #elphi2 all the technology
partners\
L.@ $ire#") is a universal data access library2 you use the same
components to connect to a huge variety of databases. The usage
pattern is similar to the +#E, and it is fully bidirectional. It also
has a large collection of specialized features for dealing with
specific databases, and local, in memory data.
L.B If you are still on the +#E, check out the $ire#") migration
guide or any of the other great $ire#") documentation. )ary
^ensen 8ust did a fabulous webinar on $ire#") including a
fabulous MA page whitepaper.
A. R*F*R*!C*S
P7Q arco @A7B. $ire#ac in #elphi -eG.
http2//blog.marcocantu.com/blog/firedacV-eG.html
P@Q ^im c_eeth @A7B. $ire#ac is the 6ecommended #atabase
"ccess (ibrary http2//delphi.org/@A7B/7@/firedac!is!
recommended/
PBQ Embarcadero Technologies @A7J. $ire#ac.
https2//www.embarcadero.com/products/rad!studio/firedac!
fa1
PJQ #FireDac : https://twitter.com/hashtag/fredac
PGQ 6ad &tudio @A7J. $ire#ac
http2//docwiki.embarcadero.com/6"#&tudio/FEG/en/$ire#
")
PLQ $ire#ac and &'( "nywhere2 http2//s1lanywhere!
forum.sap.com/1uestions/@7JM@/firedac!and!s1l!anywhere

You might also like