Designating a Primary Key
- Last Updated: February 6, 2020
- 3 minute read
- DataDirect Connectors
- JDBC
- MongoDB 6.0
- Documentation
The Schema Tool allows you to designate the primary key column for your relational table view. By default, the primary key is set to the _ID column, which contains identifiers generated by your database that are used to define rows. Although the _ID column typically provides a set of unique row identifiers that work seamlessly with your application, you may want to designate a different primary key depending on your server configuration or the conceptual design of your data.
If you connect to a shard server that does not use the _ID field as the shard key, you must designate a new primary key to ensure accurate joins on reads and avoid damaging data on writes. See your database documentation for details on shard keys.
Based on the conceptual design of your data, you may prefer to designate a user-generated column as your primary key. User generated columns consist of data provided by users that may have significance external to the database, such as order numbers or employee identification numbers. When designated as the primary key, these columns can provide a real world association between your data and your identifiers, which may better complement the design of your data and your operational needs. Designating a new primary key allows you to further tailor the relational view to match your data concepts by permitting you to hide the _ID column from relational tables. In the default settings, the Schema Tool prohibits hiding the _ID column because it is designated as the primary key. See Removing Columns for additional information.
To designate a primary key: