Skip to main content

Data Model

Recommended database schema for EWP implementations.

Naming Convention

Database column names use snake_case (standard for relational databases). JSON serialization uses camelCase. The mapping is explicit: content_hashcontentHash, created_atcreatedAt, publisher_addresspublisherAddress.

Node

Stores identity records for the self-node and all known peers.

ColumnTypeConstraintsDescription
addressstringPRIMARY KEYEthereum address (EIP-55 checksummed)
urlstringNOT NULL, UNIQUECanonical HTTPS URL
titlestringNOT NULLDisplay name
descriptionstringNULLABLENode description
ewp_versionstringNOT NULLHighest EWP version advertised
is_selfbooleanNOT NULLtrue for local node; false for peers
created_attimestampNOT NULLRecord creation time
updated_attimestampNOT NULLTime of last accepted profile update

Connection

Stores directed follow relationships.

ColumnTypeConstraintsDescription
idintegerPRIMARY KEY, AUTOSurrogate key
follower_addressstringNOT NULL, FK → nodes.addressAddress of the following node
followee_addressstringNOT NULL, FK → nodes.addressAddress of the followed node
created_attimestampNOT NULLWhen connection was established. Used for staleness checks.

Unique constraint: (follower_address, followee_address).

Content

Stores Content Units, deduplicated by hash.

ColumnTypeConstraintsDescription
content_hashstringPRIMARY KEYSHA-256 hash (0x-prefixed)
content_kindstringNOT NULLPOST or FILE
bodytextNULLABLEUTF-8 text body (POST only)
filenamestringNULLABLEOriginal filename (FILE only)
mimetypestringNULLABLEMIME type
sizeintegerNULLABLEContent size in bytes
local_pathstringNULLABLEStorage path for FILE content
created_attimestampNOT NULLWhen content was first stored

Publication

Links a Content Unit to authorship and its Proof of Source.

ColumnTypeConstraintsDescription
idintegerPRIMARY KEY, AUTOSurrogate key
content_hashstringNOT NULL, FK → contents.content_hashContent identifier
publisher_addressstringNOT NULL, FK → nodes.addressPublisher's Ethereum address
content_kindstringNOT NULLPOST or FILE (denormalized)
signaturestringNULLABLEEIP-712 signature. NULL = local-only draft.
descriptionstringNULLABLEDescription for FILE publications
slugstringNULLABLEHuman-friendly URL alias (local metadata)
timestampintegerNOT NULLUnix epoch seconds. Canonical value for PoS reconstruction.
created_attimestampNOT NULLISO 8601 representation of timestamp.
Immutability

content_hash, publisher_address, signature, content_kind, and timestamp are immutable. description and slug are local metadata and may be updated.

Entity Relationship Diagram

┌──────────────────┐ ┌───────────────────┐
│ Node │ │ Connection │
│──────────────────│ │───────────────────│
│ address (PK) │◄────────│ follower_address │
│ url │ │ followee_address │────►[ Node ]
│ title │ │ created_at │
│ description │ └───────────────────┘
│ ewp_version │
│ is_self │
│ created_at │
│ updated_at │
└────────┬─────────┘
│ 1:N

┌──────────────────────┐
│ Publication │
│──────────────────────│
│ id (PK) │
│ content_hash │──────────────────────►┌──────────────────┐
│ publisher_address │ │ Content │
│ content_kind │ │──────────────────│
│ signature │ │ content_hash (PK)│
│ description │ │ content_kind │
│ slug │ │ body │
│ timestamp │ │ filename │
│ created_at │ │ mimetype │
└──────────────────────┘ │ size │
│ local_path │
│ created_at │
└──────────────────┘