A Windows CE database — not to be confused with a full-fledged relational database — is simply a general-purpose, flexible, structured collection of data. A Windows CE database consists of records, where each record consists of one or more properties. A property refers to a data item that consists of a property identifer, a data type identifier, and the data value. For example, an application could use a database of address records, where the properties of each record include a name, street address, city, state, zip code, and telephone number. Windows CE supports integer, string, time, and byte array, or BLOB, data types.
Devices that run the Windows CE operating system usually ship with several built-in databases and allow users and applications to create additional databases. For example, the Handheld PC (H/PC) comes with calendar and task list applications that have databases for user data.
Note that databases allow only one level of hierarchy. That is, records cannot contain other records. Nor can records be shared by databases—each record is unique, has a unique object identifier, and is present in only one database. The recommended maximum size of a record in bytes is given by the constant CEDB_MAXRECORDSIZE. The recommended maximum property size is given by CEDB_MAXPROPDATASIZE. Both of these constants are defined in Rapi.h and Windbase.h.
Unlike traditional databases, opening and closing a Windows CE database does not imply that any transactioning has occurred. The database is not committed at closing, but rather it is committed after each individual call.
It is not possible to lock a Windows CE database to restrict access. Thus, several applications can have open handles to the same database at the same time. However, Windows CE supports several notification messages that can tell an application when another application creates, modifies, or deletes database records. The messages are sent to the specified window when you call CeOpenDatabase and supply a non-null window handle.
Windows CE supports the following messages:
Message | Description |
---|---|
DB_CEOID_CHANGED | Another thread modified an object in the object store. The message supplies the object identifier. |
DB_CEOID_CREATED | Another thread created an object in the object store. The message supplies the object identifier. |
DB_CEOID_RECORD_DELETED | Another thread deleted a record. The message supplies the record's object identifier. |
Each database includes information about the database as a whole, such as its name, an optional database type identifier that you can use to group similar databases, and up to four sort keys that describe how the records in the database will be sorted.