Database Schema - AnnaBullard/writers-friend GitHub Wiki
Tables:
Users
| Column |
Data Type |
Details |
| id |
serial |
PK |
| username |
varchar(25) |
unique, not null |
| email |
varchar(255) |
unique, not null |
| password |
binary |
not null |
- Sequelize hasMany
Pseudonyms association
- Sequelize hasMany
Entities association
Pseudonyms
| Column |
Data Type |
Details |
| id |
serial |
PK |
| firstName |
varchar(50) |
not null |
| middleName |
varchar(50) |
|
| lastName |
varchar(50) |
not null |
| userId |
integer |
FK:Users.id, not null |
| isActive |
boolean |
default=false |
- Sequelize belongsTo
Users association
- Sequelize hasMany
Entities association
EntityTypes
| Column |
Data Type |
Details |
| id |
serial |
PK |
| type |
varchar(13) |
not null |
- Sequelize hasMany
Entities association
This is prefilled table with default values: book series, book, chapter/story
Entities
| Column |
Data Type |
Details |
| id |
serial |
PK |
| title |
varchar(255) |
|
| description |
varchar(1000) |
|
| userId |
integer |
FK:Users.id, not null |
| pseudonymId |
integer |
FK:Pseudonyms.id |
| typeId |
integer |
FK:EntityTypes.id, not null, default="chapter/story" |
| parentId |
integer |
FK:Entities.id |
| order |
integer |
not null |
| isPublished |
boolean |
default=false |
- Sequelize belongsTo
Users association
- Sequelize belongsTo
Pseudonyms association
- Sequelize belongsTo
EntityTypes association
- Sequelize belongsTo
Entities association as "parentEntity"
- Sequelize hasMany
Entities association as "childrenEntities"
- Sequelize hasMany
Scenes association
Scenes
| Column |
Data Type |
Details |
| id |
serial |
PK |
| parentId |
integer |
FK:Entities.id, "chapter/story" only |
| order |
integer |
|
| text |
text |
not null |
- Sequelize belongsTo
Entities association