Compare commits

...

8 Commits

Author SHA1 Message Date
Vitor Pamplona dec9f4cfb1
Merge 726749bd67 into 3430b8bf3d 2025-06-05 16:31:05 +02:00
Vitor Pamplona 726749bd67 Moves from `:` to `/` for the d-tag to avoid misunderstandings when using `a` references 2024-04-09 18:27:44 -04:00
Vitor Pamplona 360cc3cce2 Making table names unique as well. 2024-04-09 18:21:40 -04:00
Vitor Pamplona 8782f982eb Adds option to use single letter to index foreign keys. 2024-04-09 18:14:06 -04:00
Vitor Pamplona 7700b94112 removing the optionality for the database name. 2024-04-09 17:44:02 -04:00
Vitor Pamplona 3f9e5d4893 making the d-tag unique. 2024-04-09 17:38:11 -04:00
Vitor Pamplona cb8e7eb54c Adds more info about the d, n and u tags. 2024-04-09 17:27:05 -04:00
Vitor Pamplona f0fe3e59f7 Generic way to represent a relational database 2024-04-09 15:59:49 -04:00
1 changed files with 44 additions and 0 deletions

44
41.md Normal file
View File

@ -0,0 +1,44 @@
NIP-41
======
Relational Database
-------------------
`draft` `optional`
This NIP offers a plug-and-play method to sync information from existing systems using relational databases into Nostr. It is an application-specific NIP 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.
The `d` tag is used for the row's primary key, the `n` tag places the row into an unbound list to represent the table and the `u` tag references a database name. Clients MAY choose their app-name as a database name to improve the likelyhood of unique table names.
Values can be public or [NIP-44](44.md) encrypted to the user and placed in the `.content` field.
```js
{
"kind": 31200,
"tags": [
["d", "<database-name/table-name/row-primary-key>"],
["n", "<database-name/table-name>"],
["u", "<database-name>"],
["<column-name>", "<column-row-value>"],
["<foreign-key-column-name or single-letter-alias>", "31200:<pubkey>:<database-name/table-name/column-row-value>"]
// other public columns
],
"content": nip44Encrypt(JSON.stringify((
[
["<column-name>", "<column-row-value>"]
// other private columns
]
)),
// .. other fields
}
```
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).
The event's `pubkey` MAY be own by the system itself and represent several users from that system.