bloomberg / bloomberg/comdb2

Support for named constraints

Open
#840 2 comments 0 reactions 1 assignee Claimed by @nirbhayc View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.