· 9 years ago · Dec 08, 2016, 02:42 PM
1
2drop table if exists Country;
3create table Country (
4 Code varchar(3) primary key not null,
5 Name varchar(52) not null unique,
6 SurfaceArea real not null,
7 Population integer not null,
8 GovernmentForm varchar(45) not null
9);
10
11drop table if exists City;
12create table City (
13 Id integer primary key not null,
14 Name varchar(35) not null,
15 CountryCode varchar(3) not null references Country (Code) on delete cascade,
16 Population integer not null
17);
18
19drop table if exists Capital;
20create table Capital (
21 CityId integer not null references City (Id) on delete cascade,
22 CountryCode varchar(3) not null references Country (Code) on delete cascade,
23 unique (CityId, CountryCode)
24);
25
26drop table if exists LiteracyRate;
27create table LiteracyRate (
28 CountryCode varchar(3) not null references Country (Code) on delete cascade,
29 Year integer not null,
30 Rate real not null,
31 unique (CountryCode, Year)
32);