Primary Key (esmane võti)

Compound Key (kompoundvõti)

Lihtsalt öeldes:
Sarnane composite key-ga – koosneb mitmest veerust. Mõnikord kasutatakse mõlemat terminit samas tähenduses.

CREATE TABLE EnrollmentCompound (
    StudentID INT,
    Kursus VARCHAR(50),
    Aasta INT,
    PRIMARY KEY (StudentID, Kursus, Aasta) -- Kompoundvõti
);

INSERT INTO EnrollmentCompound (StudentID, Kursus, Aasta) VALUES
(1, 'Matemaatika', 2025),
(1, 'Keemia', 2025),
(2, 'Füüsika', 2025);

select * from EnrollmentCompound

Lehed: 1 2 3 4 5 6 7 8 9