84 lines
1.3 KiB
Markdown
84 lines
1.3 KiB
Markdown
|
# Postgres
|
||
|
|
||
|
https://www.dbdiagram.io/d
|
||
|
|
||
|
````
|
||
|
Table User {
|
||
|
id string [primary key]
|
||
|
created_at timestamp
|
||
|
}
|
||
|
|
||
|
Table Post {
|
||
|
id varchar(25) [primary key]
|
||
|
rating Rating
|
||
|
created_at timestamp
|
||
|
}
|
||
|
|
||
|
Enum Rating {
|
||
|
safe
|
||
|
questionable
|
||
|
explicit
|
||
|
}
|
||
|
|
||
|
Table Source {
|
||
|
id varchar(25) [primary key]
|
||
|
display_name text
|
||
|
domain text [not null, unique]
|
||
|
}
|
||
|
|
||
|
Table Tag {
|
||
|
name text [primary key]
|
||
|
type TagType
|
||
|
}
|
||
|
|
||
|
Enum TagType {
|
||
|
general
|
||
|
species
|
||
|
character
|
||
|
artist
|
||
|
lore
|
||
|
meta
|
||
|
invalid
|
||
|
}
|
||
|
|
||
|
Table TagAlias {
|
||
|
name text [primary key]
|
||
|
tag_id text
|
||
|
}
|
||
|
|
||
|
Table TagGroup {
|
||
|
name text [primary key]
|
||
|
tag_id text
|
||
|
}
|
||
|
|
||
|
Table UserFavorites {
|
||
|
user_id text [primary key]
|
||
|
post_id text [primary key]
|
||
|
created_at timestamp
|
||
|
}
|
||
|
|
||
|
Table UserSource {
|
||
|
user_id text [primary key]
|
||
|
source_id text [primary key]
|
||
|
account_username text
|
||
|
account_id text
|
||
|
}
|
||
|
|
||
|
Table PostReference {
|
||
|
post_id text [primary key]
|
||
|
source_id text [primary key]
|
||
|
url text [not null, unique]
|
||
|
source_post_id text
|
||
|
}
|
||
|
|
||
|
Ref: Tag.name > TagAlias.tag_id
|
||
|
Ref: Tag.name > TagGroup.tag_id
|
||
|
Ref: Tag.name <> Post.id
|
||
|
Ref: UserFavorites.user_id > User.id
|
||
|
Ref: UserFavorites.post_id > Post.id
|
||
|
Ref: UserSource.user_id > User.id
|
||
|
Ref: UserSource.source_id > Source.id
|
||
|
Ref: PostReference.post_id > Post.id
|
||
|
Ref: PostReference.source_id > Source.id
|
||
|
|
||
|
````
|