SQL & Relational Databases (50 Qs)•Part 1: Basic & Foundational Concepts (Junior / Entry-Level)
What are Primary Keys, Foreign Keys, and Unique Constraints?
junior Levelsql-databasesBasic
In Simple Words:
- Primary Key: A column (or set of columns) that uniquely identifies each row in a table. Must be unique and cannot contain
NULLvalues. A table can have only one Primary Key. - Unique Key: Enforces uniqueness across values in a column. Unlike Primary Keys, unique columns allow
NULLvalues (often multiple NULLs depending on SQL dialect). - Foreign Key: A column that references the Primary Key of another table, enforcing referential integrity.