Tag Info

New answers tagged

1

This behavior (allowing NULL values in FK columns) conforms to the SQL standard. Per Postgres manual: The CREATE TABLE command conforms to the SQL standard, with exceptions listed below. And there is no exception listed for FK constraints. To disallow that some columns of a multi-column FK are NULL, use MATCH FULL instead of the default MATCH SIMPLE ...


1

First, a name like 'entities' is too vague. The common name for org or individual is 'parties'. Second, people can have zero, one, or many addresses, and can share the same address. It's a many2many relationship. I would do it like this (using STI here, but break it out to CTI if you like): PARTIES id type (org or individual) name ADDRESSES id type ...


3

In this special case the column actually indexed is irrelevant for the query at hand. You can pick any column. I would pick something else than uploaded_at, which is useless. Some column that may be useful for other queries and is not bigger than 8 bytes ideally. CREATE INDEX foo ON table bar (some_col) WHERE uploaded_at IS NULL; If you have no use case ...



Top 50 recent answers are included