erDiagram
ValidPaths {
int id PK
string path
string hash
int registrationTime
string deriver
int narSize
int ultimate
string sigs
string ca
}
Refs {
int referrer PK,FK
int reference PK,FK
}
DerivationOutputs {
int drv PK,FK
string id PK
int path FK
}
Invalidations {
string path PK
int time
}
ValidPaths ||--o{ Refs : "references"
ValidPaths ||--o{ DerivationOutputs : "outputs"
ValidPaths ||--o{ DerivationOutputs : "is_output"
Refs }|--|| ValidPaths : "referenced_by"
I'll create an ER diagram showing the relationships between the tables in the Nix database.
erDiagram
ValidPaths {
int id PK
string path
string hash
int registrationTime
string deriver
int narSize
int ultimate
string sigs
string ca
}
Refs {
int referrer PK,FK
int reference PK,FK
}
DerivationOutputs {
int drv PK,FK
string id PK
int path FK
}
Invalidations {
string path PK
int time
}
ValidPaths ||--o{ Refs : "references"
ValidPaths ||--o{ DerivationOutputs : "outputs"
ValidPaths ||--o{ DerivationOutputs : "is_output"
Refs }|--|| ValidPaths : "referenced_by"
Key points about the relationships shown:
ValidPathsis the central table, containing all store pathsRefshas a many-to-many relationship withValidPaths, as each path can reference multiple other paths and be referenced by multiple pathsDerivationOutputsconnects toValidPathstwice:- Once for the derivation itself (
drvfield) - Once for the output path (
pathfield)
- Once for the derivation itself (
Invalidationsis standalone as it just tracks removed paths
The diagram shows cardinality where:
||represents exactly oneo{represents zero or many}|represents many to one