sgd-praktikum/MS1/SQL/Schema.sql
2023-04-27 17:15:35 +02:00

52 lines
1.1 KiB
SQL

DROP TABLE Adress;
DROP TABLE Room;
DROP TABLE Person;
DROP TABLE Clerk;
DROP TABLE Client;
CREATE TABLE Adress
(
adressId NUMBER PRIMARY KEY,
street VARCHAR2(50) NOT NULL,
houseNumber NUMBER NOT NULL,
postalCode NUMBER NOT NULL,
city VARCHAR2(50) NOT NULL,
country VARCHAR2(50) NOT NULL
);
CREATE TABLE Room
(
roomNumber NUMBER PRIMARY KEY,
floor NUMBER NOT NULL,
roomTyp VARCHAR2(50) NOT NULL,
size NUMBER NOT NULL,
accessibility NUMBER NOT NULL,
beds NUMBER NOT NULL
);
CREATE TABLE Person
(
personId NUMBER PRIMARY KEY,
name VARCHAR2(50) NOT NULL,
lastName VARCHAR2(50) NOT NULL,
age NUMBER NOT NULL,
adressId NUMBER NOT NULL,
CONSTRAINT fkadress FOREIGN KEY (adressId) REFERENCES Adress(adressId)
);
CREATE TABLE Clerk
(
personId NUMBER PRIMARY KEY,
staff NUMBER NOT NULL UNIQUE,
salary NUMBER NOT NULL,
CONSTRAINT inheritace FOREIGN KEY (personId) REFERENCES Person(personId)
);
CREATE TABLE Client
(
personId NUMBER PRIMARY KEY,
bankDetails VARCHAR2(22) NOT NULL,
CONSTRAINT inheritace FOREIGN KEY (personId) REFERENCES Person(personId)
);