⠀
Beispiel: Create Table-Statements in PostgreSQL
Sei folgendes Beispiel gegeben:
In PostgreSQL können wir die Tabellenstruktur wie folgt anlegen:
CREATE TABLE Department ( id SERIAL PRIMARY KEY, name VARCHAR(200), city VARCHAR(200), zip_code INTEGER ); CREATE TABLE Project( id SERIAL PRIMARY KEY, department_id INTEGER, title VARCHAR(200), proj_image BYTEA, budget NUMERIC(12, 2), start_date DATE, end_date DATE, CONSTRAINT fk_department FOREIGN KEY(department_id) REFERENCES department(id) ); CREATE TABLE Employee( id SERIAL PRIMARY KEY, age INTEGER, education VARCHAR(200), recruitment_type VARCHAR(200), job_level INTEGER, rating VARCHAR(200), awards INTEGER, certifications INTEGER, salary NUMERIC(8, 1), gender VARCHAR(200), entry_date DATE, satisfied BOOLEAN, department_id INTEGER, CONSTRAINT fk_department FOREIGN KEY(department_id) REFERENCES department(id) );