CREATE TABLE vagttype (
    vagttype_id INT PRIMARY KEY,
    beskrivelse VARCHAR(50)
);

CREATE TABLE personale (
    cprnummer CHAR(10) PRIMARY KEY,
    navn VARCHAR(50),
    telefon VARCHAR(15),
    email VARCHAR(50)
);

CREATE TABLE vagt (
    vagt_id INT PRIMARY KEY,
    dato DATE,
    start_tid TIME,
    slut_tid TIME,
    cprnummer CHAR(10),
    vagttype_id INT,
    FOREIGN KEY (cprnummer) REFERENCES personale (cprnummer),
    FOREIGN KEY (vagttype_id) REFERENCES vagttype (vagttype_id)
);

-- Indsæt vagttyper
INSERT INTO vagttype (vagttype_id, beskrivelse) VALUES
(1, 'Sidde ved kassen'),
(2, 'Opsætning af varer'),
(3, 'Rengøring'),
(4, 'Hjælpe ved selvscan'),
(5,'Griete');

-- Indsæt personale med CPR-numre
INSERT INTO personale (cprnummer, navn, telefon, email) VALUES
('0101901234', 'Anna Jensen', '12345678', 'anna.jensen@example.com'),
('0202901235', 'Peter Hansen', '12345679', 'peter.hansen@example.com'),
('0303901236', 'Mette Nielsen', '12345680', 'mette.nielsen@example.com'),
('0404901237', 'Lars Pedersen', '12345681', 'lars.pedersen@example.com'),
('0505901238', 'Sofie Andersen', '12345682', 'sofie.andersen@example.com'),
('0606901239', 'Mads Kristensen', '12345683', 'mads.kristensen@example.com'),
('0707901240', 'Kasper Sørensen', '12345684', 'kasper.sorensen@example.com'),
('0808901241', 'Emilie Thomsen', '12345685', 'emilie.thomsen@example.com'),
('0909901242', 'Frederik Møller', '12345686', 'frederik.moller@example.com'),
('1000901243', 'Laura Poulsen', '12345687', 'laura.poulsen@example.com'),
('1000100000','Laureke Polusonn','1234576','laure.polse@example.com');

-- Indsæt vagter
INSERT INTO vagt (vagt_id, dato, start_tid, slut_tid, cprnummer, vagttype_id) VALUES
(1, '2025-03-05', '08:00:00', '12:00:00', '0101901234', 1),
(2, '2025-03-05', '12:00:00', '16:00:00', '0202901235', 2),
(3, '2025-03-05', '16:00:00', '20:00:00', '0303901236', 3),
(4, '2025-03-06', '08:00:00', '12:00:00', '0404901237', 4),
(5, '2025-03-06', '12:00:00', '16:00:00', '0505901238', 1),
(6, '2025-03-06', '16:00:00', '20:00:00', '0606901239', 2),
(7, '2025-03-07', '08:00:00', '12:00:00', '0707901240', 3),
(8, '2025-03-07', '12:00:00', '16:00:00', '0808901241', 4),
(9, '2025-03-07', '16:00:00', '20:00:00', '0909901242', 1),
(10, '2025-03-08', '08:00:00', '12:00:00', '1000901243', 2),
(11, '2025-03-08', '12:00:00', '16:00:00', '0101901234', 3),
(12, '2025-03-08', '16:00:00', '20:00:00', '0202901235', 4),
(13, '2025-03-09', '08:00:00', '12:00:00', '0303901236', 1),
(14, '2025-03-09', '12:00:00', '16:00:00', '0404901237', 2),
(15, '2025-03-09', '16:00:00', '20:00:00', '0505901238', 3),
(16, '2025-03-10', '08:00:00', '12:00:00', '0606901239', 4),
(17, '2025-03-10', '12:00:00', '16:00:00', '0707901240', 1),
(18, '2025-03-10', '16:00:00', '20:00:00', '0808901241', 2),
(19, '2025-03-11', '08:00:00', '12:00:00', '0909901242', 3),
(20, '2025-03-11', '12:00:00', '16:00:00', '1000901243', 4),
 (21,'2025-04-12','12:00:00','17:00:00','10009021243',5)  : 

SELECT 

vagt.dato,
vagt.start_tid,
vagt.slut_tid,
personale.navn,
vagttype.beskrivelse

FROM

personale

INNER JOIN vagt on personale.cprnummer=vagt.cprnummer
INNER JOIN vagttype ON vagttype.vagttype_id=vagt.vagttype_id
   where personale.cprnummer = '0505901238' ;

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: