diff --git a/code/db/ERP.png b/code/db/ERP.png new file mode 100644 index 0000000..1e606e9 Binary files /dev/null and b/code/db/ERP.png differ diff --git a/code/db/README.md b/code/db/README.md new file mode 100644 index 0000000..f971e59 --- /dev/null +++ b/code/db/README.md @@ -0,0 +1,71 @@ +This is DBML Code. It can be edited and viewed on [dbdiagram.io](https://dbdiagram.io/d) + +``` +// Use DBML to define your database structure +// Docs: https://dbml.dbdiagram.io/docs + +Table follows { + following_user_id integer + followed_user_id integer + created_at timestamp +} + +Table users { + id integer [primary key] + username varchar [unique] + role varchar + email string + password string + created_at timestamp +} + +Table posts { + id integer [primary key] + title varchar + body text [note: 'Content of the post'] + user_id integer [not null] + status varchar + file string + created_at timestamp +} + +Table comments { + id integer [primary key] + post_id integer + content string + created_at timestamp +} +Table likes { + id integer [primary key] + post_id integer + user_id integer + created_at timestamp + +} +Table tags { + id integer [primary key] + name varchar [unique] +} + +Table post_tags { + post_id integer + tag_id integer +} + +Ref: post_tags.post_id > posts.id +Ref: post_tags.tag_id > tags.id + + +Ref: likes.user_id < users.id + +Ref: likes.post_id < posts.id + +Ref: posts.id < comments.post_id + +Ref user_posts: posts.user_id > users.id // many-to-one + +Ref: users.id < follows.following_user_id + +Ref: users.id < follows.followed_user_id + +```