-- alias -> users constraint
ALTER TABLE aliases ADD CONSTRAINT deliver_to_fk FOREIGN KEY (deliver_to) REFERENCES users(user_idnr) MATCH FULL;

-- mailboxes -> users constraint 
ALTER TABLE mailboxes ADD CONSTRAINT owner_idnr_fk FOREIGN KEY (owner_idnr) REFERENCES users(user_idnr) MATCH FULL;

-- messages -> mailboxes constraint
ALTER TABLE messages ADD CONSTRAINT message_idnr_fk FOREIGN KEY (message_idnr) REFERENCES mailboxes(mailbox_idnr) MATCH FULL;

-- messageblks -> messages constraint 
ALTER TABLE messageblks ADD CONSTRAINT messageblk_idnr_fk FOREIGN KEY (messageblk_idnr) REFERENCES messages(message_idnr) MATCH FULL;

-- auto_notifications -> users
ALTER TABLE auto_notifications ADD CONSTRAINT user_idnr_anfk FOREIGN KEY (user_idnr) REFERENCES users(user_idnr) MATCH FULL;

-- auto_replies -> users
ALTER TABLE auto_replies ADD CONSTRAINT user_idnr_arfk FOREIGN KEY (user_idnr) REFERENCES users(user_idnr) MATCH FULL;
