Главная страница | назад

Article #22113: Indices Vs. Keys

Question: When dealing with databases, what is the difference between keys and indices?

Answer: An index is a marker in a table which other tables can operate upon.  A key is a value that a table uses internally to order its data.

Imagine you had a table of customers, working with a table of orders.  Your orders would be keyed by their order numbers, and your customers by their customer numbers.

This is fine until we want to view our orders in terms of which customers made them. We would then use an index into the orders table. Using this index, we could find all of the orders which were made by a certain customer, even though the table itself isn't ordered in this fashion.

Last Modified: 27-OCT-00