Our group was debating the pros and cons of DB2 versus Unisys RDMS while trying to design some new tables. Our debate became a little heated (as tech conversations do sometimes). Could you resolve a few questions regarding the physical implementation of DB2 tables for us please?
  1. Is a primary key required, and if so, must it be specified that it is sorted ascending/descending?
  2. If a primary key is defined, are the keys themselves physically stored separately (in a different table) from their data rows? Are the data rows physically stored in the primary key sequence?
Thank you very much for your time. Hopefully our group won't have to get out the boxing gloves.

    Requires Free Membership to View

OK, I can definitely help, but don't put away those boxing gloves just yet! I doubt these answers will be able to 100% settle any technology dispute.

First of all, DB2 does not require a primary key to be defined for each table. That being said, it is a good idea to define a primary key for every table. Without one, duplicate rows can exist and they can be very problematic to manage. Every primary key, though, requires a unique index to be defined for that key. The index data is maintained automatically and will be stored in a different underlying data set.

Secondly, the primary key will be composed of a column (or group of columns) in the table. Therefore, these columns exist in the same table as the rest of the data. The rows will not be sequenced by the primary key column(s) unless you specifically request them to be by making the primary key index a clustering index.

I'm intrigued by these questions... I wonder what all the fighting was about?

For More Information

This was first published in December 2002

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: