Just create a foreign key that refers to the field in the other table. That will enforce pre-existing values like you are asking.
Also, it's worth noting that if immobilien-id
is guaranteed to be unique, that should be the only primary key instead of using a composite primary key. You want to keep them as simple as you can.
CREATE TABLE verwalten (
immobilien-id NUMBER NOT NULL,
PRIMARY KEY(name, immobilien-id),
FOREIGN KEY(name) REFERENCES immobilienmakler(name)
);
Note: Number is more commonly used as it is also valid in oracle. It also allows fine-tuning of precision, which should be thought about.
Reference:
https://www.w3schools.com/sql/sql_foreignkey.asp
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…