Adds option to use single letter to index foreign keys.

This commit is contained in:
Vitor Pamplona 2024-04-09 18:14:06 -04:00
parent 7700b94112
commit 8782f982eb

15
41.md
View File

@ -6,7 +6,7 @@ Relational Database
`draft` `optional` `draft` `optional`
This NIP offers a plug-and-play method to export/sync information from existing systems using relational databases into Nostr. This NIP offers a plug-and-play method to export/sync information from existing systems using relational databases into Nostr. It is an application specific type where interoperability with other Nostr apps is not expected.
Event kind `31200` represents a row in a database. Each value of the row is added as a tag whose name is the column's name. Event kind `31200` represents a row in a database. Each value of the row is added as a tag whose name is the column's name.
@ -18,10 +18,11 @@ Values can be public or encrypted to the user.
{ {
"kind": 31200, "kind": 31200,
"tags": [ "tags": [
["d", "<database-name:table-name:row-primary-key>"] ["d", "<database-name:table-name:row-primary-key>"],
["n", "<table-name>"] ["n", "<table-name>"],
["u", "<database-name>"] ["u", "<database-name>"],
["<column-name>", "<column-row-value>"] ["<column-name>", "<column-row-value>"],
["<foreign-key-column-name or single-letter-alias>", "<database-name:table-name:column-row-value>"]
// other public columns // other public columns
], ],
"content": nip44Encrypt(JSON.stringify(( "content": nip44Encrypt(JSON.stringify((
@ -34,6 +35,10 @@ Values can be public or encrypted to the user.
} }
``` ```
Foreign key values should be adjusted to match the corresponding `d`-tag they point to.
Since column names are arbitraryly defined by the data source, such data source might also decide to map certain names to single letters to enable indexing by that column when on Nostr.
Inserts and updates are supported via Nostr's regular signing operations and deletions via [NIP-09](09.md). Inserts and updates are supported via Nostr's regular signing operations and deletions via [NIP-09](09.md).
The pubkey MAY be own by the system and represent several users from that system. The pubkey MAY be own by the system and represent several users from that system.