ArticleslgStudy

computer science

SQL Server Compact

SQL Server Compact is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand SQL Server Compact rather than just read about it. In short: Microsoft SQL Server Compact (SQL CE) is a discontinued relational database produced by Microsoft for applications that run on mobile devices and desktops. Prior to the introduction of the desktop platform, it was known as SQL Server for Windows CE and SQL Server Mobile Edition.

Key takeaways

  • SQL Server Compact belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect SQL Server Compact to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of SQL Server Compact from memory before moving on to harder problems.

Reference excerpt

Microsoft SQL Server Compact (SQL CE) is a discontinued relational database produced by Microsoft for applications that run on mobile devices and desktops. Prior to the introduction of the desktop platform, it was known as SQL Server for Windows CE and SQL Server Mobile Edition. It includes both 32-bit and 64-bit native support. SQL CE targets occasionally connected applications and applications with an embedded database. It is free to download and redistribute. An ODBC driver for SQL CE does not exist, nor is one planned. Native applications may use SQL CE via OLE DB. The latest, and last, release is SQL Server Compact 4.0. In February 2013 SQL Server Compact Edition had been deprecated; no new versions or updates are planned, although Microsoft continued to support the product until July 2021.

Overview SQL Server Compact shares a common API with the other Microsoft SQL Server editions. It also includes ADO.NET providers for data access using ADO.NET APIs, and built-in synchronization capabilities, as well as support for LINQ and Entity Framework. Future releases will unify the synchronization capabilities with Microsoft Synchronization Services. Unlike other editions of Microsoft SQL Server, SQL CE runs in-process with the application which is hosting it. It has a disk footprint of less than 2 MB and a memory footprint of approximately 5 MB. SQL CE is optimized for an architecture where all applications share the same memory pool. Windows Store apps for Windows 8 cannot use SQL Server Compact edition, or any other edition of SQL Server.

Support SQL CE databases can support ACID-compliance, but do not meet the durability requirement by default because AutoFlush buffers changes in memory (including enlisted ambient transactions and explicit SQL CE transactions that do not override the Commit() call with an CommitMode.Immediate value). Therefore, committed transaction changes can be lost. To meet the durability requirement the commit call on the transaction must specify the immediate flag. Like Microsoft SQL Server, SQL CE supports transactions, referential integrity constraints, locking as well as multiple connections to the database store. However, nested transactions are not supported, even though parallel transactions (on different tables) are. The current release does not support stored procedures or native XML data type either. It uses a subset of T-SQL for querying and due to lack of XML support, XQuery is not supported either. Queries are processed by an optimizing query processor. SQL CE databases also support indexing, as well as support remote data replication (local caching of data in remote databases) and merge replication (bidirectional synchronization with master databases). SQL CE databases can be created and managed from Microsoft Visual Studio and some older versions of SQL Server Management Studio as well.

File format

SQL CE databases reside in a single .sdf file, which can be up to 4 GB in size. The .sdf file can be encrypted with 128-bit encryption for data security. SQL CE runtime mediates concurrent multi-user access to the .sdf file. The .sdf file can simply be copied to the destination system for deployment, or be deployed through ClickOnce. SQL CE runtime has support for DataDirectories. Applications using an SQL CE database need not specify the entire path to an .sdf file in the ADO.NET connection string, rather it can be specified as |DataDirectory|\<database_name>.sdf, defining the data directory (where the .sdf database file resides) being defined in the assembly manifest for the application. SQL Server Management Studio 2005 can read and modify CE 3.0 and 3.1 database files (with the latest service pack), but SQL Server Management Studio 2008 (or later) is required to read version 3.5 files. Microsoft Visual Studio Express 2008 SP1 can create, modify, and query CE 3.5 SP1 database files. SQL Server Management Studio cannot read CE 4.0 files. Visual Studio 2010 SP1 can handle CE 4.0 database files. The .sdf ("Sqlce Database File") naming convention is optional, and any extension can be used. Setting a password for the database file is optional. The database can be compressed and repaired with the option of the compacted/repaired database to be placed into a new database file.

Deprecation In February 2013, Microsoft announced that SQL Server Compact Edition had been deprecated. Although no new versions or updates are planned, Microsoft will continue to support SQL Compact through their standard lifecycle support policy. Extended support for SQL Server Compact 4.0 ended on July 13, 2021.

See also Mobile database SQLite SQL Server Express § LocalDB Access Database Engine (ACE and formerly JET) HSQLDB Firebird

References

External links Microsoft's Embedded Database - SQL Server Compact - Team Blog at Microsoft Learn Microsoft's Embedded Database - SQL Server Compact - Team Blog at the Wayback Machine (archived 2016-02-15)

Worked examples

Example 1 — a first encounter with SQL Server Compact

Start with the simplest possible case. Write down what SQL Server Compact claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to SQL Server Compact before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about SQL Server Compact ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of SQL Server Compact

In research
SQL Server Compact appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses SQL Server Compact in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
SQL Server Compact is common in secondary-school and first-year university syllabi. It links to neighbouring topics Discontinued Microsoft software, Microsoft database software, Microsoft server technology, so understanding it makes those chapters shorter.
In everyday life
Look for SQL Server Compact outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “SQL Server Compact” →

How to study SQL Server Compact in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what SQL Server Compact means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain SQL Server Compact out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is SQL Server Compact in simple terms?

Microsoft SQL Server Compact (SQL CE) is a discontinued relational database produced by Microsoft for applications that run on mobile devices and desktops. Prior to the introduction of the desktop platform, it was known as SQL Server for Windows CE and SQL Server Mobile Edition.

Why does SQL Server Compact matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study SQL Server Compact?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on SQL Server Compact.

Tags

  • Discontinued Microsoft software
  • Microsoft database software
  • Microsoft server technology
  • Relational database management systems
  • Windows Mobile

Keep exploring