Choosing Between SQL Server 2005 Compact Edition and SQL Server 2005 Express Edition
Choosing Between SQL Server 2005 Compact Edition and SQL Server 2005 Express Edition
Choosing Between SQL Server 2005 Compact Edition and SQL Server 2005 Express Edition
White Paper
Choosing Between SQL Server 2005 Compact Edition and SQL Server 2005 Express Edition
2
Overview
Even in this new age of Internet connectivity, online services and wireless everywhere,
architects, developers, and end users are realizing that betting their business and user
productivity on a constant connection to a central location is a risky, frustrating, and costly
endeavour. When the connection goes down for any reason, can you afford to have your
business stop? Building resiliency, redundancy and the ability to work independently within
your application architecture provides the ability to shield your users and company bottom-
line from inevitable problems. Having a local data store to cache online data, enable offline
functionality, or enable that stand alone application that just doesn’t need to serve data to
the world asks the question; “What should I use for local storage?”
The SQL Server family offers two products suitable for local storage: Microsoft SQL Server
2005 Compact Edition and Microsoft SQL Server 2005 Express Edition. With the release
Compact Edition for desktop scenarios, Microsoft is positioning Compact Edition as the
default local database. However, both editions are free to download and deploy. Choosing
between the SQL Server Express and SQL Server Compact edition of SQL Server 2005 can
be difficult because they seem to target the same scenarios. This paper helps developers
understand the benefits of each edition and when each edition should be used for local data
storage.
As you read this paper, it is important to remember that you need to choose the right tool
for the right job. One size does not fit all. SQL Server 2005 is available in multiple editions
because each is designed to fit a specific purpose. As you will learn from this paper, if you
are looking to decide which database to use for your central data service, or the local
database for your Windows Mobile device, your choices are easy, and you can read this
paper for casual information.
If you’re looking for a local data store for a Tablet PC, laptop, desktop in a remote office, or
simply looking to add some local caching features to your connected call center application,
you’ll discover some interesting features and issues that may not be obvious when you first
look at the features of SQL Server Express Edition and the “not so new engine on the block”
— SQL Server 2005 Compact Edition.
1
Serving one client doesn’t imply support for a single connection, rather a single machine establishing a connection.
Choosing Between SQL Server 2005 Compact Edition and SQL Server 2005 Express Edition
3
• SQL Server Standard Edition – Data service engine targeting small and medium-
sized organizations and includes entry point features for business intelligence.
• SQL Server Enterprise Edition – Data service engine targeting large enterprises
with advanced tools, analytics, data warehousing features, fault-tolerance and other
enterprise-level features.
Embedded Database Engine Family:
• SQL Server Compact Edition – A lightweight, in-process database engine designed
to run on devices and desktops and is geared toward local data storage. Compact
Edition includes a subset of SQL Server 2005 data types and shares common
elements of the Transact-SQL (T-SQL) language with the data service engines.
XML
XML and other text-based technologies work well as a persistence and serialization format,
but they lack the rich query functionality, data manipulation, and transactional functionality
offered by database engines.
Microsoft SQL Server Express Edition and SQL Server Compact Edition
SQL Server Express Edition is the evolution of MSDE and addresses many of the common
problems of MSDE related to ease of packaging and deployment. Requiring administrative
rights to install, Express Edition dramatically smaller than MSDE, but at approximately
53MB, is still quite large for most client deployment scenarios. Express Edition has also been
Choosing Between SQL Server 2005 Compact Edition and SQL Server 2005 Express Edition
4
extended to better support local data storage when the full functionality of a data service
engine is required.
SQL Server Compact Edition isn’t a new product but rather the evolution of the SQL Server
family of products that have been shipping on the Microsoft Mobile platform for several
years. Originally launched in 2000, SQL Server CE 1.0 shipped with Embedded VB (eVB)
and Embedded VC (eVC). Visual Studio 2003 shipped SQL Server CE 2.0 as the local store
for the compact framework. Responding to customers who wanted a common local store
from device to Tablet PC, SQL Server CE became SQL Server Mobile 3.0 and shipped with
Visual Studio 2005. In November 2006, SQL Server Mobile became SQL Server Compact
Edition enabling the SQL Server CE engine for the entire desktop platform and removed the
restriction to devices and the Tablet PC. SQL Server Compact Edition is designed to meet
the needs of applications where it is important to embed a lightweight data engine directly
into the application.
While several Microsoft products shipped MSDE, several other Microsoft products were
quietly shipping the SQL Server Compact Edition engine, such as Media Center PC, MSN
Client, and several applications within Windows Vista. The product teams recognized the
need for a core set of database features and decided to ship the SQL Server Compact
Edition engine as their local data store to millions of users. The SQL Server Compact Edition
engine wasn’t visible to the user as it was considered part of the application. That’s the key
differentiator.
The data store features discussed in this paper go beyond the traditional server-centric
measurements of Transaction Processing Council (TPC) benchmarks and multi-user security.
A local database needs to share its environment with a different set of challenges. We don’t
suspend, resume, or hibernate servers. We don’t watch movies, play games, run Outlook or
present Power Points from our servers. We don’t think about the power usage
characteristics and whether the server would last a day on batteries, charging nightly. And
we don’t measure the installation and disk footprint of a server as critically as we tend to
install and configure far fewer servers compared to each client.
Figure 1 shows two scenarios that have a single solution. When you require data service
functionality, such as the ability to support multiple, remote users, you should start with
SQL Server Express Edition and work up the data service family tree. If you need a data
store for the Pocket PC, Smart Phone platform, or you need the same data store ranging
from Smart Phone to desktop, SQL Server Compact Edition is the appropriate choice. This
paper focuses on the core features that are important for a local data store and
differentiates SQL Server Express and SQL Server Compact editions based on those
features.
Choosing Between SQL Server 2005 Compact Edition and SQL Server 2005 Express Edition
5
START
HERE
SCENARIOS
Local
Data Service
Data Store
DATA STORES
{
Clear choice for
Embedded
Database
{
category
Focus of this
white paper
Figure 1: Decision Tree for SQL Server Compact Edition and SQL Server Express Edition.
Data Services
A Data Service is a database engine that provides database functionality to clients from
{
remote connections. If your application provides central data services to remote clients,
Figure 1 shows the SQL Server data service products available: SQL Server 2005 Express,
Clear
Choosing Between choice
SQL Server 2005for
Compact Edition and SQL Server 2005 Express Edition
Database Server 6
category
Workgroup, Standard, or Enterprise Edition. Here you can range from the small and free
data service to the full scale, fault tolerant data services of SQL Server Enterprise Edition.
Local Data Stores
A local data store provides core functionality needed from a relational database engine,
including rich query functionality, transactions, persistence, and the common datatypes
used on a data service platform. The database is accessed from one client, although isn’t
limited to a single connection. Examples may range from caching product catalogs, states,
and status codes to rich personal accounting applications. The application may communicate
with a central data service, but it needs local storage to increase performance or the
application must function when connectivity isn’t available. Microsoft Outlook 2003
demonstrates the blur between local and central storage. As you interact with Outlook, most
of your operations are performed against the local data store. When a connection to the
Exchange server is available, the local store is synchronized with the central data service.
The user may never notice if the connection drops.
Mobile Devices
For the purposes of this paper, a mobile device is any piece of hardware that runs on the
Windows Mobile or Windows CE platforms. Referring to Figure 1, you’ll see that for an
application that requires a local data store and targets a mobile device, SQL Server 2005
Compact Edition is your clear choice.
Desktop Databases
For the purposes of this paper, a desktop database simply refers to the non-mobile Windows
platform, including Windows XP, Windows Tablet PC, Windows 2000, Windows Vista, and
Windows 2003 Server. If your application requires a local data store that targets the
desktop platform, you can select SQL Server 2005 Compact Edition (which belongs to the
embedded database family) or SQL Server 2005 Express Edition (which belongs to the data
service family of products). Microsoft recommends SQL Server Compact Edition as the
default local database. However, if your application requires some of the data service
features, SQL Server Express Edition may be necessary.
The rest of this paper focuses on helping you decide whether SQL Server 2005 Compact
Edition or SQL Server 2005 Express Edition is the correct choice for your local desktop
application data store.
Choosing Between SQL Server 2005 Compact Edition and SQL Server 2005 Express Edition
7
Feature SQL Server SQL Server
Compact Edition Express Edition
Deployment/Installation Features
Installation size 1.7mb download size 53.8mb download size
1.8mb expanded on disk ~197mb expanded on disk
ClickOnce deployment
Privately installed, embedded, with
the application
Non-admin installation option
Runs on Windows Mobile platform
Installed centrally with an MSI
Runs in-process with application
64-bit support Version 3.1
Windows on Windows
Native 64 in next version (WOW)
Runs as a service In process with the
application N+1
Data file features
File format Single file Multiple files
Data file storage on a network share
Support for different file extensions
Database size support 4GB 4GB
XML storage stored as nText
Code free, document safe, file format
Programmability
Transact-SQL
Common Query Features
Procedural T-SQL
Select Case, If, features
Remote Data Access (RDA)
ADO.NET Sync Framework Enabled with Visual Studio Planed support with a future
Orcas version
Subscriber for merge replication
Simple transactions
Distributed transactions
Native XML, XQuery/QPath
Stored procedures, views, triggers
Role-based security
Number of concurrent connections 256 Unlimited
Table 1: Feature Comparison Between Compact Edition and Express Edition.
Choosing Between SQL Server 2005 Compact Edition and SQL Server 2005 Express Edition
8
Comparing features of the two database engines doesn’t really tell the full story. A number
of philosophical and functional questions need to be answered to make the right choice for
local data storage. Some of the important factors to consider when choosing your local data
store are discussed in the following sections.
ClickOnce Support
Both SQL Server Express and SQL Server Compact editions can be incorporated into the
setup of your application. ClickOnce can assist in deploying either engine as a pre-requisite
for your application. SQL Server Express Edition which runs as a Windows Service must be
installed with an MSI. SQL Server Compact Edition has an MSI deployment model to
centrally install the engine, which requires administrative rights as well. However SQL
Server Compact Edition, being a set of DLLs that run in-process with the hosting application,
can be privately deployed with the application. Private deployment does not require
administrative rights.
Choosing Between SQL Server 2005 Compact Edition and SQL Server 2005 Express Edition
9
SQL Server Compact Edition, starting from the other end of the spectrum, was designed to
be small and easy to deploy from its inception. Mobile devices, such as the Pocket PC and
Smartphone, don’t have complex installation environments, nor do they have many
resources. SQL Server Compact Edition, which runs in-process with the hosting application,
doesn’t have any services or other options to be configured during installation. SQL Server
Compact Edition exposes its configuration options within the connection string, allowing
each instance to specify parameters specific to that application usage scenario. These DLLs
can be centrally installed on a user’s computer with an MSI. However, using the MSI does
require administrative rights to register the ADO.NET managed provider within the Global
Assembly Cache (GAC). The same DLLs can also be privately deployed within the hosting
application. Client applications, such as those deployed with ClickOnce are typically installed
under the user’s Documents & Settings folders, which means the installation process does
not require administrative rights.
One of the other benefits of private deployment is dependency tracking. Should a user
decide to uninstall your application, there are no additional steps for the application and
data store to be completely uninstalled. Using the central MSI deployment model requires
your application to either reference count the usage of the database engine, or to simply
require the user to know that uninstalling the product doesn’t return the environment to its
original state.
Choosing Between SQL Server 2005 Compact Edition and SQL Server 2005 Express Edition
10
support for a common programming model between their local database and their data
service. However, sometimes you have to re-examine why these standards were created,
and question if they still apply.
While stored procedures can range from simple to complex, developers and DBAs typically
refer to three core reasons they standardize on stored procedures: performance, abstraction
and security. Consider the fact that many service databases can be used by several
applications at the same time. As the database grows in its usage, columns and tables are
added to the ever-expanding data requirements. Load on the database may increase in
certain “hot-spots,” requiring the DBA to tune the database with schema changes. Since a
data service doesn’t always “own,” or even know which individual applications are utilizing
its data, any internal changes to the schema must be abstracted from any interacting
applications. This is why many DBAs remove table level interaction and only enable access
via stored procedures and views.
Likewise, many different users, and types of users access the data service simultaneously.
Users may have different roles and therefore should have different access levels to the data.
Stored procedures and views provide a safety gate to limit the role of a user to certain data
operations. A given role is given a set of permissions to different stored procedures and
views.
Performance issues are often managed with stored procedures to cache query plans, and
tune queries within stored procedures to avoid having to make changes to the application.
When you consider an embedded database is by definition part of the application, the same
rules don’t necessarily apply. The database is versioned with the application, therefore the
abstraction issues don’t apply and the benefits for having to author and maintain stored
procedures aren’t realized. Since the local data should already be partitioned to the data
allowed by a user’s role, the security issues don’t necessarily apply either. Performance of
cached query plans are realized when many concurrent operations are occurring from a
large number of users. The overhead of maintaining query plans aren’t an issue in a server
environment as servers tend to have larger amounts of dedicated memory. As query plans
change, a DBA can optimize these query plans on the server.
Another category of issues covered by stored procedures relate to procedural operations.
These may range from maintaining a last edit column, maintaining a star-schema table, or
implementing business rules. Certainly these operations may still exist within a local
database. However, given the choice, you may not want to limit your ability to write code in
only T-SQL, even if the full T-SQL language is supported. Instead, you may opt to take
advantage of the full breadth of your favourite .NET managed code language. Additional
innovations such as LINQ and the ADO.NET Entity Data Model provide an even broader set
of functionality at your disposal.
Choosing Between SQL Server 2005 Compact Edition and SQL Server 2005 Express Edition
11
database is local to the application, the developer has a lot more flexibility to perform
complex queries that would be highly problematic in a data service environment, but highly
productive and insightful to a user. In a local database, complex switches from being
expensive to highly valuable.
The point here doesn’t actually suggest that stored procedures couldn’t be used locally as
well. The point is that the stored procedures you create on the server would likely not
represent the types of queries that you would write on the client. Consider a similar scenario
closer to home. How do you keep your home stocked to prepare specific meals for your
family? You would synchronize the food in your kitchen with a filtered set of raw materials
at the store. While your local food market may provide some pre-packaged meals, it could
never maintain the variety of foods and different varying levels of spices for each customer.
Similarly, the server may not actually answer many of the specific questions. The server
may expose a set of stored procedures and services to keep the local database in sync with
the server. The stored procedures return deltas of the data locally compared to the data on
the server enabling the client application, and the application developer to provide a broad
range of questions without requiring a DBA to optimize each and every question.
Choosing Between SQL Server 2005 Compact Edition and SQL Server 2005 Express Edition
12
Securing Your Local Data
Security is always a big part of any application’s design. SQL Server Express and SQL
Server Compact editions are both secure platforms that are designed to help you protect
your sensitive data. The way each edition manages security is different, and the differences
should be considered when making your engine choice for local data storage. This section
contains an overview of the security design principles for each engine and then contrasts
how that design impacts different security threats your local data store may face.
Physical Security
Both database engines being discussed store data in one or more files. The most significant
way for anyone to protect their data is to limit physical access to the file so that only users
who require access to the data can actually get to the file. Physical security includes using
appropriate Windows-based security to control access to the file on disk and security of the
facility and equipment where the data file resides. There are too many current news stories
about confidential data being lost that resulted from criminals having improper access the
physical files or equipment where the files were stored. Therefore, physical file security is
too important to be ignored.
Choosing Between SQL Server 2005 Compact Edition and SQL Server 2005 Express Edition
13
over”. If the user has gotten this far, it’s likely easier to simply walk away with the physical
drive or the whole computer. SQL Server Express Edition, like the rest of the data service
SKUs rely heavily on physical security to prevent unauthorized people from getting to the
database file. Breaking into a computer room is not easy; however, connecting to a data
service remotely is a feature. Connecting remotely is a feature that is off by default in SQL
Server Express Edition.
The data service family of SQL Server products implements role-based security and offer
several security options related to how connections are made to the server. The data
service editions can implement table, column, and row-level encryption. The connection to
the database must be authorized before any data can be returned. The HR manager may
have permissions to view and edit salary information but can’t change product pricing.
Sounds pretty secure; doesn’t it? Absolutely! The SQL Server data service family of products
has some of the best security features in the industry by securing data before and while it
travels across the wire.
Permissions in a role-based security model are assigned by special users in the data service
editions including System Administrators, Database Administrators and Database Owners.
These high level users have no, or few, restrictions regarding access to a database, which
has some implications when using SQL Server Express Edition as a local data store. For
example, a System Administrator has full access to any SQL Server Express Edition
database file that they posses. If the database file used for the local store is not physically
protected and can be stolen by a criminal, that criminal could then access your data by
attaching the database to their own copy of SQL Server Express Edition where they are a
System Administrator.
Choosing Between SQL Server 2005 Compact Edition and SQL Server 2005 Express Edition
14
runs in the context of the user, that user is considered to be the Database Owner and can
accomplish all the necessary tasks related to working with Express Edition. Additional users
on the same machine will not have access to other user instances — only their own.
User Instances allow separation of users by providing a unique instance of Express Edition
for each user, but it also gives the user complete control over the databases attached to the
User Instance. Once running, the owner of the User Instance can view and edit every part of
the database including schema, data and feature configuration regardless of permissions,
passwords or encryption applied to the database objects. Again, protection of the database
file using physical security is important. For local data scenarios where laptops are regularly
stolen, it’s important to understand that Express Edition User Instances could be another
avenue that could allow rogue users access to your database if they can get possession of
the file.
Choosing Between SQL Server 2005 Compact Edition and SQL Server 2005 Express Edition
15
safe format, Compact Edition data files can use any file extension, enabling you to associate
a recipe application with a .recipe extension. Double clicking on your .recipe file from your
friend could launch a recipe application, just as you might open a Microsoft Office document.
While not as powerful as data service files, with SQL Server Compact Edition files you don’t
need to worry about code executing on your behalf.
Choosing Between SQL Server 2005 Compact Edition and SQL Server 2005 Express Edition
16
This is where the security features of Windows can be leveraged. Implementing a strong
password policy is the first place to start. However, if your users don’t lock their laptop,
then your enemy simply needs to grab your laptop and they can view the same data you
can. It’s easy to forget to lock you computer when you leave it unattended, but Windows
offers two ways to automatically lock a computer. Use the Power Options Properties within
the Control Panel to prompt for a password when your laptop resumes from standby. This
option is shown in Figure 2.
The second Windows security feature leverages the Screen Saver Properties to lock the
laptop after your screen saver kicks in. Setting the wait threshold to low can be annoying as
your user must constantly type in their password. Many new laptops, incorporate a
fingerprint reader that while not foolproof, balances security with usability slowing down
your enemy, while making it easy for your users. This option is shown in Figure 3.
Choosing Between SQL Server 2005 Compact Edition and SQL Server 2005 Express Edition
17
available. SQL Server Express Edition can only use EFS when the data file is used in
conjunction with User Instances. Database files attached to the main instances of SQL
Server Express Edition cannot use EFS because the file is being opened by the SQL Server
Express Edition service account, not the current user.
When using EFS, a user cannot copy the file without acknowledging they are loosing their
ability to encrypt the data file. Windows EFS also blocks users from opening and copying
files that are encrypted by other uses and prevents mounting of hard drives or access via an
accidental shared folder exposed via your wireless network card. Figure 4 shows how to
configure EFS and the warnings that appear.
Combining the security features of SQL Server Express or SQL Server Compact editions,
with the security features of Windows, provides a higher level of security than either
mechanism alone. Improved security allows you to leverage the increased productivity
available when data is stored locally and users are not required to be connected to the
network for all data access.
Measuring Performance
Typically, when someone asks how well a database performs, they start quoting
transactions per second metrics. How many concurrent queries, inserts, updates, and
deletes can be performed within a one second interval? When thinking about a local data
store, it is important to return results quickly, but a user can only type so fast. Even when
using a barcode scanner, there is a practical limit to how much data someone can enter.
Likewise, how many questions can a single user ask of their local data store?
Local data stores are components of an overall application: an application that shares the
same resources as the database. Users multi-task by running multiple applications at the
same time. A typical user may have Outlook opened to monitor their email and calendar.
The user may be editing a PowerPoint presentation using Microsoft Word to track their
notes. Instant messenger, and/or Office Communicator run minimized in the corner waiting
for the latest sales figures. Internet Explorer continually updates the current traffic
conditions while you’re listening to your favorite music with Windows Media Player. Outlook
reminds you of a meeting with your partner at the local coffee shop. Once you get to the
Choosing Between SQL Server 2005 Compact Edition and SQL Server 2005 Express Edition
18
coffee shop, you want to quickly show the progress you’ve made on the presentation, so
you close your laptop entering stand-by or hibernate mode without closing any of the
running applications. On the way you forgot where the coffee shop is located, so while at
the traffic light, you open your laptop to resume your applications and view your calendar.
Can you imagine the reaction you would get from your DBA when you asked them to tune
the database for this environment? In a client environment, you measure performance by
the overall productivity of the user. Data services are typically hosted on dedicated servers
and are tuned to perform thousands of operations per second. They are optimized to
leverage any and all resources available. Similarly, tractor trailers can haul enormous loads
across country. They take a little longer to start and stop, but once they’re rolling, they are
massively powerful. On the other hand, a motorcycle can quickly start and stop on a dime.
It can zip in and out of traffic around the city, parking in the smallest of spots, delivering
messages within minutes. A 53’ tractor trailer may not be the best thing to deliver
messages around the city, but they can transport a lot more materials for longer hauls
compared to that motorcycle.
SQL Server Compact Edition runs in-process with the application. Designed for devices, it is
very efficient with resources and won’t force applications to page to disk when you start
executing queries. Since Compact Edition doesn’t run as a service, it doesn’t consume any
resources when it is not being used, which directly affects startup, shutdown, suspend and
resume time.
SQL Server Express Edition does spin down when not in use for several minutes. When
compared to its siblings, it is much more efficient in reducing the active memory to a
surprisingly small working set. However, because SQL Server Express Edition was designed
around a server-based environment, it runs recovery on each attached database when it
resumes hibernation. When it spins up, it consumes more memory as it is geared to process
thousands of transactions and multiple clients concurrently. When you enter hibernate
mode, it has to page all that memory to disk, even if no applications were using it at the
time.
Conclusion
One size does not fit all. Selecting the right tool for the job is important when choosing a
local data storage engine. Both SQL Server 2005 Express Edition and SQL Server 2005
Compact Edition are available for free. SQL Server Compact Edition, designed as the default
local data store for client applications, targeting phones, PDA’s, Tablet PCs, and desktops,
provides unique features for client deployment and security. SQL Server Express Edition,
designed as a data service for applications, provides a consistent programming model as its
data service family providing an overlap of scenarios for local storage. This intention of this
paper is to describe the local data storage challenges, the functional benefits of each
database engine model, and identifying the trade-offs you’ll need to consider when choosing
a local data store.
Using the Microsoft platform, businesses and developers are empowered to build people-
ready applications that leverage your business data anytime, everyplace, and everywhere.
Choosing Between SQL Server 2005 Compact Edition and SQL Server 2005 Express Edition
19
The information contained in this document represents the current view of Microsoft Corporation on the issues discussed as of the date of publication.
Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft
cannot guarantee the accuracy of any information presented after the date of publication.
This white paper is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS DOCUMENT.
Complying with all applicable copyright laws is the responsibility of the user. Without limiting the rights under copyright, no part of this document may
be reproduced, stored in, or introduced into a retrieval system, or transmitted in any form or by any means (electronic, mechanical, photocopying,
recording, or otherwise), or for any purpose, without the express written per of Microsoft Corporation.
Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property rights covering subject matter in this document.
Except as expressly provided in any written license agreement from Microsoft, the furnishing of this document does not give you any license to these
patents, trademarks, copyrights, or other intellectual property.
© 2005 Microsoft Corporation. All rights reserved.
The example companies, organizations, products, domain names, e-mail addresses, logos, people, places, and events depicted herein are fictitious.
No association with any real company, organization, product, domain name, e-mail address, logo, person, place, or event is intended or should be
inferred.
Microsoft, Visual Basic, Visual Studio, Win32, Windows, and Windows Server, SQL Server are either registered trademarks or trademarks of
Microsoft Corporation in the United States and/or other countries.
All other trademarks are property of their respective owners.
Choosing Between SQL Server 2005 Compact Edition and SQL Server 2005 Express Edition
20