SQLize Online / PHPize Online

A A A
Share   Donate   Blog   Popular
Copy Format Clear
CREATE TABLE Konto ( KontoID int, Name text, EMail varchar(50) UNIQUE, Punkte int CHECK ( Punkte >= 0 AND Punkte <= 999 ), PRIMARY KEY (KontoID) ); CREATE TABLE Eintrag ( PostID int, Autor int, Datum date, Anonym bool, PRIMARY KEY (PostID), FOREIGN KEY (Autor) REFERENCES Konto (KontoID) ); CREATE TABLE Kommentar ( PostID int, KontoID int, Zeit timestamp, Text text CHECK ( LENGTH (Text) <= 1024 ), PRIMARY KEY (Zeit), FOREIGN KEY (KontoID) REFERENCES Konto (KontoID), FOREIGN KEY (PostID) REFERENCES Eintrag (PostID) ); INSERT INTO Konto (KontoID, Name, EMail, Punkte) VALUES ( 1000, "Viola F", "viola@mail.com", 50 ), ( 1001, "Natan S.", "natan@mail.com", 10 ), ( 1002, "Oscar H.", "oscar@mail.com", 30 ), ( 1003, "Klara W.", "klara@mail.com", 70 ); INSERT INTO Eintrag (PostID, Autor, Datum, Anonym) VALUES (10, 1002, "2005-11-13", TRUE), (11, 1000, "2005-11-17", FALSE), (12, 1001, "2005-11-21", FALSE), (13, 1002, "2005-11-25", TRUE); INSERT INTO Kommentar (KontoID, Zeit, Text, PostID) VALUES ( 1003, "2005-11-13 11:45:00.000", "A!", 10 ), ( 1001, "2005-11-13 12:15:00.000", "A?", 10 ), ( 1002, "2005-11-17 11:15:00.000", "B?", 11 ), ( 1003, "2005-11-25 12:45:00.000", "C!", 13 );
Stuck with a problem? Need help? Ask professionals on our Telegram channel!
Join the channel
Your quersion is posted.
Join our Telegram channel and get answers.
Send
Copy