[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/emacsql a362a97c98 136/427: Add README section on foreign
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/emacsql a362a97c98 136/427: Add README section on foreign keys. |
Date: |
Tue, 13 Dec 2022 02:59:36 -0500 (EST) |
branch: elpa/emacsql
commit a362a97c98569045056a4be576ffa4c137aa0814
Author: Christopher Wellons <wellons@nullprogram.com>
Commit: Christopher Wellons <wellons@nullprogram.com>
Add README section on foreign keys.
---
README.md | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 9a9c7764be..e58c86ce2b 100644
--- a/README.md
+++ b/README.md
@@ -63,7 +63,7 @@ allowed) types are `integer`, `float`, and `object` (default).
Columns constraints include `:primary` (aka `PRIMARY KEY`), `:unique`,
`:non-nil` (aka `NOT NULL`), `:default`, and `:check`.
-Table constraints can be `:primary`, `:unique`, and `:check`.
+Table constraints can be `:primary`, `:unique`, `:check`, and `:foreign`.
```el
;; No constraints schema with four columns:
@@ -77,6 +77,25 @@ Table constraints can be `:primary`, `:unique`, and `:check`.
:unique [building room] :check ())
```
+Foreign keys are the most complex. Action triggers are `:on-delete`
+or `:on-update` and possible actions are `:set-nil`, `:set-default`,
+`:restrict`, `:cascade`. See [the SQLite documentation][foreign] for
+the details on what each of these means.
+
+`:foreign (<child-keys> <parent-table> <parent-keys> [<actions>])`.
+
+```el
+;; "subject" table
+[(id integer :primary) subject]
+
+;; "tag" table references subjects
+([(subjectid integer) tag]
+ :foreign (subjectid subject id :on-delete :cascade))
+```
+
+Put the keys in a vector if the reference is composite, but remember
+that the cardinality must match.
+
## Operators
Emacsql currently supports the following expression operators, named
@@ -276,3 +295,4 @@ types. This is a high-performance database specifically for
Emacs.
[readable]:
http://nullprogram.com/blog/2013/12/30/#almost_everything_prints_readably
[stderr]: http://thread.gmane.org/gmane.comp.db.sqlite.general/85824
+[foreign]: http://www.sqlite.org/foreignkeys.html
- [nongnu] elpa/emacsql beb0e00b9e 100/427: Rename emacsql--vars-collect., (continued)
- [nongnu] elpa/emacsql beb0e00b9e 100/427: Rename emacsql--vars-collect., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql ee2877dab0 106/427: Clearer error message from escape identifier., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql e9b77b4774 112/427: Add a test for CREATE TABLE., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 652847dbf5 110/427: Allow memoization cache to be nil (for development)., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql ff4c59a2a7 113/427: Fix cl-lib mistake., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql f794d4d38f 116/427: Allow for selected columns in :insert-into., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql cefe1ec014 121/427: Add emacsql-sqlite3-unavailable-p., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql b2d83c6477 123/427: Fix up ORDER BY, drop :ascending-by., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql f52af86b05 124/427: Break apart and organize compilation tests., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 0bff8ccc34 126/427: Fix up README., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql a362a97c98 136/427: Add README section on foreign keys.,
ELPA Syncer <=
- [nongnu] elpa/emacsql 223db2d397 141/427: Add quote operator., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 8951084b40 143/427: Add variable escaping., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 19a65f390e 147/427: Add ignored features section to README., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 530b0ad98c 151/427: Allow arbitrary sub-statements., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 3012f5b725 154/427: Fix typo., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 301e2ff4b6 175/427: Drop "simple" from helper method names., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 578a71d2d8 157/427: Re-order some definitions to group them., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 935cca89a9 176/427: Add updated information about Windows., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql b3aea1e6af 055/427: Oops, fix >= back., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql c4396ec5e6 057/427: Fix a bunch of warnings., ELPA Syncer, 2022/12/13