The case is about a client who can reserve films. But he is only allowed to have a max of 10 films in his possession at any given time. What check constraint do I need to let this work?
The code to create my database is as followed:
CREATE TABLE Genre (PK_GenreID AUTOINCREMENT(13, 1) NOT NULL, GenreNaam TEXT(20),
PRIMARY KEY (PK_GenreID));
CREATE UNIQUE INDEX Index_BC00E533_C727_4D6E ON Genre(GenreNaam);
CREATE TABLE Klant (PK_Klantnummer AUTOINCREMENT(19, 1) NOT NULL, Naam TEXT(20) NOT NULL, Woonplaats TEXT(20), Postcode TEXT(6), Huisnummer TEXT(6), Telefoon TEXT(10), Email TEXT(255),
CONSTRAINT PrimaryKey PRIMARY KEY (PK_Klantnummer));
CREATE UNIQUE INDEX Index_6827B6DC_E76F_4B57 ON Klant(Naam);
CREATE TABLE Reserveringen (PK_ReserveringID AUTOINCREMENT(13, 1) NOT NULL, FK_Klantnummer INTEGER, Reserveringsdatum DATE, PRIMARY KEY (PK_ReserveringID),
CONSTRAINT KlantReserveringen FOREIGN KEY (FK_Klantnummer) REFERENCES Klant(PK_Klantnummer) ON UPDATE CASCADE ON DELETE CASCADE);
CREATE TABLE Films (PK_FilmnaamID AUTOINCREMENT(51, 1) NOT NULL, FK_GenreID INTEGER, Filmnaam TEXT(30) WITH COMPRESSION, Releasedatum DATE, Regisseur TEXT(30), CONSTRAINT PrimaryKey PRIMARY KEY (PK_FilmnaamID),
CONSTRAINT GenreFilms FOREIGN KEY (FK_GenreID) REFERENCES Genre(PK_GenreID) ON UPDATE CASCADE ON DELETE CASCADE);
CREATE INDEX PK_FilmnaamID ON Films(PK_FilmnaamID);
CREATE TABLE Beelddrager (PK_FilmID AUTOINCREMENT(50, 1) NOT NULL, FK_FilmnaamID INTEGER, Soort TEXT(50), PRIMARY KEY (PK_FilmID),
CONSTRAINT FilmsBeelddrager FOREIGN KEY (FK_FilmnaamID) REFERENCES Films(PK_FilmnaamID) ON UPDATE CASCADE ON DELETE CASCADE);
CREATE TABLE Beschadiging (PK_BeschadigingID AUTOINCREMENT(14, 1) NOT NULL, FK_FilmID INTEGER, Schade TEXT(255), Datum DATE, CONSTRAINT PrimaryKey PRIMARY KEY (PK_BeschadigingID),
CONSTRAINT BeelddragerBeschadiging FOREIGN KEY (FK_FilmID) REFERENCES Beelddrager(PK_FilmID) ON UPDATE CASCADE ON DELETE CASCADE);
CREATE INDEX PK_BeschadigingID ON Beschadiging(PK_BeschadigingID);
CREATE TABLE Reserveringsregel (FK_ReserveringID INTEGER, FK_FilmID INTEGER, Begindatum DATE, Einddatum DATE, CONSTRAINT BeelddragerReserveringsregel FOREIGN KEY (FK_FilmID) REFERENCES Beelddrager(PK_FilmID) ON UPDATE CASCADE ON DELETE CASCADE, CONSTRAINT ReserveringenReserveringsregel FOREIGN KEY (FK_ReserveringID) REFERENCES Reserveringen(PK_ReserveringID) ON UPDATE CASCADE ON DELETE CASCADE);