-
Notifications
You must be signed in to change notification settings - Fork 276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cascade or restrict on delete entities? #4672
Comments
|
To consider entity relationships, I drew what if the storages under the world were tables of relational database: erDiagram
%% parent tables
DOMAINS {
_ id PK
_ logo
_ metadata
_ admin FK
}
ACCOUNTS {
_ id PK
_ metadata
}
ASSETS {
_ id PK
_ total_quantity
_ is_mintable
_ logo
_ metadata
_ admin FK
}
%% child tables
DOMAIN_ACCOUNTS {
_ domain_id PK, FK
_ account_id PK, FK
}
DOMAIN_ASSETS {
_ domain_id PK, FK
_ asset_id PK, FK
}
ASSET_ACCOUNTS_NUMERIC {
_ asset_id PK, FK
_ account_id PK, FK
Numeric balance
}
ASSET_ACCOUNTS_STORE {
_ asset_id PK, FK
_ account_id PK, FK
Metadata datastore
}
%% relationships
DOMAINS ||--o{ DOMAIN_ACCOUNTS : has
DOMAINS ||--o{ DOMAIN_ASSETS : has
ACCOUNTS ||--o{ DOMAINS : administrates
ACCOUNTS ||--o{ ASSETS : administrates
ACCOUNTS ||--o{ DOMAIN_ACCOUNTS : has
ACCOUNTS ||--o{ ASSET_ACCOUNTS_NUMERIC : has
ACCOUNTS ||--o{ ASSET_ACCOUNTS_STORE : has
ASSETS ||--o{ DOMAIN_ASSETS : serves
ASSETS ||--o{ ASSET_ACCOUNTS_NUMERIC : serves
ASSETS ||--o{ ASSET_ACCOUNTS_STORE : serves
erDiagram
%% parent tables
ACCOUNTS {
_ id PK
_ metadata
}
PERMISSIONS {
_ id PK
}
ROLES {
_ id PK
}
%% child tables
ACCOUNT_PERMISSIONS {
_ account_id PK, FK
_ permission_id PK, FK
}
ACCOUNT_ROLES {
_ account_id PK, FK
_ role_id PK, FK
}
ROLE_PERMISSIONS {
_ role_id PK, FK
_ permission_id PK, FK
}
%% relationships
ACCOUNTS ||--o{ ACCOUNT_PERMISSIONS : has
ACCOUNTS ||--o{ ACCOUNT_ROLES : has
PERMISSIONS ||--o{ ACCOUNT_PERMISSIONS : serves
PERMISSIONS ||--o{ ROLE_PERMISSIONS : serves
ROLES ||--o{ ROLE_PERMISSIONS : has
ROLES ||--o{ ACCOUNT_ROLES : serves
where:
|
Interesting, when you visualized it this way i noticed that either removal of account or domain can have cascade a lot. Like:
|
As long as ACCOUNTS serves DOMAINS, as suggested, the removal of the domain owner would be restricted. But yeah, this is exactly the kind of discussion I wanted to have |
updates:
erDiagram
%% parent tables
DOMAINS {
_ id PK
_ logo
_ metadata
_ admin FK
}
ACCOUNTS {
_ id PK
_ metadata
_ domain_id FK
}
FASSETS {
%% fungible assets
_ id PK
Numeric total_quantity
_ is_mintable
_ logo
_ metadata
_ admin FK
_ domain_id FK
}
NFASSETS {
%% non-fungible assets
_ id PK
Metadata datastore
_ owner FK
_ domain_id FK
}
%% child tables
FASSET_ACCOUNTS {
_ asset_id PK, FK
_ account_id PK, FK
Numeric balance
}
%% relationships
DOMAINS ||--o{ ACCOUNTS : has
DOMAINS ||--o{ FASSETS : has
DOMAINS ||--o{ NFASSETS : has
ACCOUNTS ||--o{ DOMAINS : administrates
ACCOUNTS ||--o{ FASSETS : administrates
ACCOUNTS ||--o{ FASSET_ACCOUNTS : has
ACCOUNTS ||--o{ NFASSETS : has
FASSETS ||--o{ FASSET_ACCOUNTS : serves
where:
|
Currently, domains, accounts, and assets are cascaded on unregister due to nested structure, but for shallow objects #3921 we might choose either of the following unregister policies:
The text was updated successfully, but these errors were encountered: