CREATE TYPE school_type AS ENUM ('college', 'high_school');
CREATE TABLE schools (
id SERIAL PRIMARY KEY,
type school_type,
unique (id, type)
);
CREATE TABLE colleges (
id INTEGER NOT NULL,
type school_type default 'college',
check (type='college'),
foreign key (id, type) references school(id, type)
);
Ya, the syntax is annoying and repetitive. It would be nice if foreign key could be a literal to remove the extra column altogether. e.g.: foreign key (id, 'college') references school(id, type) Because table partitioning is less general than table inheritance, it
is hoped that it will be easier to reason about properties of
partitions, and therefore that this will serve as a better foundation
for a variety of possible optimizations, including query planner
optimizations. { "mrow": [
{ "mi": "x" },
{ "mo": "=" },
{ "mfrac": [
{ "mrow": [
{ "mo": "-" },
{ "mi": "b" },
{ "mo": "±" },
{ "sqrt": {
{ "mrow": [
{"mi": "b"},
{"msup": { "mi": 2 }},
{"mo": "-"},
{"mi", "4ac"}
]}
}}
},
{ "mrow": [
{"mi": "2a"}
]}
]}
}
It's not as general, but works if you know your syntax is similarly bounded. I don't know how certain static languages would handle serial/deserializing, but makes construction via javascript literals much more pleasant.
https://learn.microsoft.com/en-us/sql/relational-databases/n...