Can a foreign key contain NULL?

You have two tables: customers(id) and orders(customer_id). A table-level constraint, FOREIGN KEY (customer_id) REFERENCES customers(id), links them, but the orders.customer_id column allows NULL. Why do PostgreSQL and MySQL 8.4 (InnoDB) allow an order with customer_id = NULL? What happens in each database if you provide a specific customer_id (not NULL) that doesn't exist in customers? How would you define the schema so that every order must have a customer? How would the same relationship behave in ClickHouse?

ExplainNULLMiddleBackendData EngineerQA