71 lines
No EOL
1.7 KiB
SQL
71 lines
No EOL
1.7 KiB
SQL
DROP TABLE Adress;
|
|
DROP TABLE Room;
|
|
DROP TABLE Person;
|
|
DROP TABLE Clerk;
|
|
DROP TABLE Client;
|
|
DROP TABLE Booking;
|
|
|
|
|
|
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)
|
|
);
|
|
|
|
CREATE TABLE Booking (
|
|
bookindId NUMBER PRIMARY KEY,
|
|
arrivalDate DATE NOT NULL,
|
|
departueDate DATE NULL,
|
|
cost NUMBER NULL,
|
|
pensionType VARCHAR2(20) NOT NULL.
|
|
lateCheckout NUMBER NULL,
|
|
clientId NUMBER NOT NULL,
|
|
FOREIGN KEY (clientId) REFERENCES Person(personId)
|
|
);
|
|
|
|
CREATE TABLE BookingGuest (
|
|
bookingId NUMBER NOT NULL,
|
|
personId NUMBER NOT NULL,
|
|
PRIMARY KEY(bookingId, personId)
|
|
FOREIGN KEY (bookingId) REFERENCES Booking(bookindId),
|
|
FOREIGN KEY (personId) REFERENCES Person(personId)
|
|
); |