Support for named constraints
- Dominant language
- C
- Stars
- 1.5k
- Forks
- 243
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 37
Description
In order to support the use of constraints in DDL commands, we need to extend CSC2 to accept names for foreign key constraints. Later, we can also add support for unique and check constraints. In order to preserve backwards compatibility.
Proposed format:
```
constraints
{
/* ---------- Old syntax ---------- */
/* Old-style, unnamed FK constraint, can accept a list of parent keys */
"key" -> <"table":"key">[<"table":"key">[...]]
/* FOREIGN KEY constraint : Named FK constraint */
"fk-cons-name" = "key" -> <"table":"key">
/* ---------- New syntax ---------- */
/* FOREIGN KEY constraint (new style) */
FOREIGN "fk-cons-name" = "key" -> <"table":"key">
/* UNIQUE constraint: Must refer to a 'unique' key in keys section */
UNIQUE "unique-cons-name" = "key"
/* CHECK constraint: Won't accept sub-queries */
CHECK "check-cons-name" = { where expr }
}
```
All constraints defined for a table must be unique identifiers.
Contributor guide
Assessment
This issue has not been assessed yet.