Keys

  • Primary Keys: Uniquely identify individual records in a relational database. Essential for data integrity and efficient retrieval. Example: "employee number" as a unique identifier.

  • Foreign Keys: Establish connections between related tables by referencing the primary key of another table. Example: "customer ID" in an "orders" table linking to a "customers" table.

  • Types of Keys:

    • Simple Key: A single field that uniquely identifies a record.

    • Composite Key: Multiple fields that together form a unique identifier, used when single fields are not unique enough.

  • Indexes and Query Optimization: Keys often serve as indexes, enhancing data retrieval speed. Indexes create quick references for locating data, speeding up user queries.