CIM to ODBC Mapping

[This is preliminary documentation and subject to change.]

The Common Information Model (CIM) maps to ODBC as follows:

CIM namespaces map to ODBC databases.
In CIM, namespaces are instances of the __NameSpace class. Namespaces can contain child namespaces, which can be enumerated like any other instance of a class.
CIM classes map to ODBC tables.
The table qualifier is the fully qualified __NameSpace name. A class is unique. If a class exists in two different namespaces, the adapter maps them as two different tables.
CIM class properties map to table columns as follows:

The property qualifiers are exposed to the ODBC clients by using SQLColumns. Some of the metadata is used to determine the standard metadata exposed by SQLColumns. All qualifiers are contained as a SQL_LONGVARCHAR in a thirteenth column added to the resultant rowset. The adapter only exposes qualifiers on a per-class basis, not on a per-class, per-instance basis. Therefore, information in qualifiers that vary over instances is inaccessible. See SQLColumns for more information.

CIM class qualifiers map to metadata of a table (as exposed through SQLTables).
A sixth column of the rowset has been added to SQLTables to return all class qualifiers as an SQL_LONGVARCHAR. For more information, see SQLTables. The adapter exposes qualifiers on a per-class basis only. Therefore, the adapter does not access qualifier information that varies across instances.
CIM data types map to ODBC SQL data types.
CIM uses variants to return property values. The ODBC adapter supports these variant types. The CIMTYPE attribute has more semantics than the variant type. For example, if the variant type is BSTR and the CIMTYPE is IpAddress, the variant BSTR is in fact an IP address. The adapter uses the CIMTYPE attribute sparingly. For more information on data types, see Appendix D of the ODBC 2.0 Programmer's Reference and SDK Guide.

The following table shows the mapping of variant types to ODBC types.

Variant Type Data source-Dependent Name CIMTYPE String SQL Type
VT_UI1 UINT8 UINT8 SQL_TINYINT
VT_I2 SINT8 SINT8 SQL_TINYINT
VT_I2 SINT16 SINT16

Default case if nothing else matches

SQL_SMALLINT
VT_I4 UINT16 UINT16 SQL_SMALLINT
VT_I4 UINT32 UINT32 SQL_INTEGER
VT_I4 SINT32 SINT32

Default case if nothing else matches

SQL_INTEGER
VT_BSTR SINT64 SINT64 SQL_BIGINT
VT_BSTR UINT64 UINT64 SQL_BIGINT
VT_BSTR INTERVAL INTERVAL SQL_TIMESTAMP
VT_BSTR TIMESTAMP DATETIME SQL_TIMESTAMP
VT_BSTR DATE DATE SQL_DATE
VT_BSTR TIME TIME SQL_TIME
VT_BSTR SMALL_STRING STRING

The property must also have a MAX qualifier with a value <= 254.

Default case if nothing else matches

If the MAX qualifier value cannot be retrieved, the default value of 254 is used.

SQL_VARCHAR
VT_BSTR STRING STRING

The property must also have a MAX qualifier with value > 254.

If MAX qualifier value > 16384, it is truncated to 16384.

SQL_LONGVARCHAR
VT_R4 REAL SQL_DOUBLE
VT_R8 DOUBLE SQL_DOUBLE
VT_BOOL BIT SQL_BIT
VT_ARRAY | VT_UI1 SINT8_ARRAY SINT8 SQL_LONGVARBINARY
VT_ARRAY | VT_I2 UINT8_ARRAY UINT8 SQL_LONGVARBINARY
VT_ARRAY | VT_I2 SINT16_ARRAY SINT16

Default case if nothing else matches

SQL_LONGVARBINARY
VT_ARRAY | VT_I4 UINT16_ARRAY UINT16 SQL_LONGVARBINARY
VT_ARRAY | VT_I4 UINT32_ARRAY UINT32 SQL_LONGVARBINARY
VT_ARRAY | VT_I4 SINT32_ARRAY SINT32

Default case if nothing else matches

SQL_LONGVARBINARY
VT_ARRAY | VT_BOOL BOOL_ARRAY SQL_LONGVARBINARY
VT_ARRAY | VT_R4 REAL_ARRAY SQL_LONGVARBINARY
VT_ARRAY | VT_R8 DOUBLE_ARRAY SQL_LONGVARBINARY
VT_ARRAY | VT_BSTR SINT64_ARRAY SINT64 SQL_LONGVARBINARY
VT_ARRAY | VT_BSTR UINT64_ARRAY UINT64 SQL_LONGVARBINARY
VT_ARRAY | VT_BSTR STRING_ARRAY STRING

Default case if nothing else matches

SQL_LONGVARBINARY
VT_ARRAY | VT_BSTR INTERVAL_ARRAY INTERVAL SQL_LONGVARBINARY
VT_ARRAY | VT_BSTR TIMESTAMP_ARRAY DATETIME SQL_LONGVARBINARY
VT_ARRAY | VT_BSTR DATE_ARRAY DATE SQL_LONGVARBINARY
VT_ARRAY | VT_BSTR TIME_ARRAY TIME SQL_LONGVARBINARY

As the table shows, CIM supports multiple array types. These array types are returned as binary data. However, through ODBC, these array values can also be returned as ASCII strings. For example:

Use SQLColumns to get the data source-dependent type in order to distinguish between [-3][200][50][45] as an array of integers and an array of strings (which just look like numbers).

If an array name or value contains a left or right square bracket within itself, the brackets are doubled in the ASCII representation. For example, fr[ed]dy is shown as:

[fr[[ed]]dy]

CIM class and property qualifiers that change with the instance of a class are not exposed.

CIM associations are only exposed insofar as they are represented by classes. Thus, foreign keys are not used in a table to relate the classes of an association.

An ODBC data source can include several databases. See Connecting to a Data Source for information on database configuration.