Add database schema
This commit is contained in:
parent
202276eb8f
commit
f6b7212199
45
README.md
45
README.md
@ -14,4 +14,47 @@ Sleep Tracker is intended for anyone interested in improving their sleep and hea
|
|||||||
|
|
||||||
## Possible further features
|
## Possible further features
|
||||||
- Make recommendations not only based on sleep time, but also on bed time (some reasearch will need to be done in that area)
|
- Make recommendations not only based on sleep time, but also on bed time (some reasearch will need to be done in that area)
|
||||||
- Connect to third party sleep tracking services
|
- Connect to third party sleep tracking services
|
||||||
|
|
||||||
|
## Database Schemas
|
||||||
|
|
||||||
|
### Users | `users`
|
||||||
|
| field | data type | metadata |
|
||||||
|
| :--------| :--------------- | :-------------------------------------------------- |
|
||||||
|
| id | unsigned integer | primary key, auto-increments, generated by database |
|
||||||
|
| email | string | required |
|
||||||
|
| username | string | required |
|
||||||
|
| password | string | required |
|
||||||
|
|
||||||
|
### Sleep Sessions | `sessions`
|
||||||
|
|
||||||
|
| field | data type | metadata |
|
||||||
|
| :------------ | :--------------- | :-------------------------------------------------- |
|
||||||
|
| id | unsigned integer | primary key, auto-increments, generated by database |
|
||||||
|
| user_id | unsigned integer | foreign key referencing users.id, required |
|
||||||
|
| bed_time | unsigned integer | timestamp with date, required |
|
||||||
|
| wake_time | unsigned integer | timestamp with date, required |
|
||||||
|
| bed_tiredness | unsigned integer | between 1-5, |
|
||||||
|
| wake_mood | unsigned integer | between 1-5, |
|
||||||
|
| day_mood | unsigned integer | between 1-5, |
|
||||||
|
|
||||||
|
### Average Mood per Sleep Session | `moods`
|
||||||
|
| field | data type | metadata |
|
||||||
|
| :------------- | :--------------- | :--------------------------------------------------- |
|
||||||
|
| id | unsigned integer | primary key, auto-increments, generated by database |
|
||||||
|
| session_date | unsigned integer | foreign key referencing sessions.wake_time |
|
||||||
|
| sleep_duration | unsigned integer | |
|
||||||
|
| average_mood | float | average of bed_tiredness/wake_mood/day_mood |
|
||||||
|
|
||||||
|
## API Endpoints
|
||||||
|
- `POST /api/users` - add a new user
|
||||||
|
- `GET /api/users/:id` - fetch a user
|
||||||
|
- `PUT /api/users/:id` - update a user
|
||||||
|
|
||||||
|
- `GET /api/sessions` - fetch list of all sessions
|
||||||
|
- `POST /api/sessions` - add a session
|
||||||
|
- `GET /api/sessions/:id` - get a single session by id
|
||||||
|
- `PUT /api/sessions/:id` - update a session by user id
|
||||||
|
- `DELETE /api/sessions/:id` - delete a session by user id
|
||||||
|
|
||||||
|
- `GET /api/moods/:id` - fetch a list of last 30 moods by user id
|
Loading…
Reference in New Issue
Block a user