Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. DROP TABLE IF EXISTS CRIMES;
  2. CREATE TABLE IF NOT EXISTS CRIMES
  3. (
  4. PRIMARY KEY (id),
  5. id INT NOT NULL IDENTITY,
  6. name VARCHAR(45) NOT NULL,
  7. min_sentence INT NOT NULL,
  8. max_sentence INT NULL,
  9. lifetime TINYINT NOT NULL,
  10. description VARCHAR(1000) NULL
  11. );
  12. DROP TABLE IF EXISTS PRISONERS;
  13. CREATE TABLE IF NOT EXISTS PRISONERS
  14. (
  15. PRIMARY KEY (id),
  16. id INT NOT NULL IDENTITY,
  17. name VARCHAR(45) NOT NULL,
  18. surname VARCHAR(45) NOT NULL,
  19. sentence_start DATE NOT NULL,
  20. sentence_duration VARCHAR(45),
  21. lifetime TINYINT NOT NULL,
  22. crime_id INT NOT NULL,
  23. CONSTRAINT fk_user_crime
  24. FOREIGN KEY (crime_id)
  25. REFERENCES CRIMES (id)
  26. );
  27. INSERT INTO CRIMES (name, min_sentence, max_sentence, description, lifetime)
  28. VALUES ('theft', 90, 1800,
  29. 'the felonious taking and removing of personal property with intent to deprive the rightful owner of it',
  30. 0),
  31. ('murder', 3600, null, 'the unlawful premeditated killing of one human being by another', 1),
  32. ('drug possesion', 180, 2250,
  33. 'having one or more illegal drugs in one''s possession, either for personal use, distribution, sale or otherwise',
  34. 0);
  35. INSERT INTO PRISONERS(name, surname, sentence_start, sentence_duration, lifetime, crime_id)
  36. VALUES ('Jan', 'Kowalski', '2014-12-12', 100, 0, 2),
  37. ('Janusz', 'Nowak', '1970-02-03', null, 1, 1),
  38. ('Zbigniew', 'Malinowski', '2012-05-03', 250, 0, 0);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement