Skip to content

Instantly share code, notes, and snippets.

@Merce0897
Created December 18, 2022 08:47
Show Gist options
  • Save Merce0897/292bc3339b08cf0d0352a287bb192b2a to your computer and use it in GitHub Desktop.
Save Merce0897/292bc3339b08cf0d0352a287bb192b2a to your computer and use it in GitHub Desktop.
CREATE TABLE driver(
driver_id INTEGER,
country TEXT NOT NULL,
zip_code TEXT NOT NULL,
PRIMARY KEY(driver_id)
);
CREATE TABLE car(
car_id INTEGER,
brand TEXT NOT NULL,
model TEXT NOT NULL,
year INTEGER NOT NULL,
driver_id INTEGER,
PRIMARY KEY(car_id),
FOREIGN KEY(driver_id) REFERENCES driver(driver_id)
);
CREATE TABLE accident(
accident_id INTEGER,
accident_date TEXT NOT NULL,
location TEXT NOT NULL,
PRIMARY KEY(accident_id)
);
CREATE TABLE car_accident(
car_id INTEGER NOT NULL,
accident_id INTEGER NOT NULL,
compensation REAL NOT NULL,
PRIMARY KEY(car_id, accident_id),
FOREIGN KEY(car_id) REFERENCES car(car_id),
FOREIGN KEY(accident_id) REFERENCES accident(accident_id)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment