add a foreign key constraint to the cities table
This commit is contained in:
parent
122bee4bbd
commit
23f348b365
|
@ -204,7 +204,8 @@ Enthält die möglichen Anreden für Personen.
|
||||||
|
|
||||||
\textbf{cities / (Städte)}
|
\textbf{cities / (Städte)}
|
||||||
\newline
|
\newline
|
||||||
Enthält Städtenamen sowie die dazugehörige Postleizahl.
|
Enthält Städtenamen sowie die dazugehörige Postleizahl und einem
|
||||||
|
Verweis zu welchem Land die jeweilige Stadt gehört.
|
||||||
|
|
||||||
\textbf{countries / (Länder)}
|
\textbf{countries / (Länder)}
|
||||||
\newline
|
\newline
|
||||||
|
|
|
@ -111,6 +111,7 @@ if not exists (select * from sysobjects where name='cities')
|
||||||
city_id int identity not null,
|
city_id int identity not null,
|
||||||
city_name varchar(50) not null,
|
city_name varchar(50) not null,
|
||||||
zip_code int not null,
|
zip_code int not null,
|
||||||
|
country_id int not null,
|
||||||
constraint city_pk primary key (city_id)
|
constraint city_pk primary key (city_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -157,6 +158,11 @@ if not exists (select * from sysobjects where name='rent_prices')
|
||||||
|
|
||||||
-- Add constraints
|
-- Add constraints
|
||||||
|
|
||||||
|
use marketdb;
|
||||||
|
IF OBJECT_ID('dbo.[fk_cit_country_id]', 'F') IS NULL
|
||||||
|
ALTER TABLE cities ADD CONSTRAINT fk_cit_country_id
|
||||||
|
FOREIGN KEY (country_id) REFERENCES countries (country_id);
|
||||||
|
|
||||||
use marketdb;
|
use marketdb;
|
||||||
IF OBJECT_ID('dbo.[fk_com_member_id]', 'F') IS NULL
|
IF OBJECT_ID('dbo.[fk_com_member_id]', 'F') IS NULL
|
||||||
ALTER TABLE commercials ADD CONSTRAINT fk_com_member_id
|
ALTER TABLE commercials ADD CONSTRAINT fk_com_member_id
|
||||||
|
|
Loading…
Reference in New Issue