Junior — Middle
Can you explain what the term 'key' means in the context of a database table?
sobes.tech AI
Answer from AI
In the context of a database, the term "key" in a table refers to one or more fields (columns) used to uniquely identify each record (row) in the table.
Main types of keys:
- Primary Key — a unique identifier for a record, does not allow duplicates or NULLs.
- Foreign Key — a field that references the primary key of another table, establishing a relationship between the tables.
For example, in a users table, the user_id field can be a primary key, uniquely identifying each user.