Skip to content

Database Schema

Shawn edited this page May 10, 2019 · 4 revisions

Database Schema

users (Normalized)

Column Name Date Type Content
id integer primary key, auto increment
username string not null
first_name string
password_digest string not null
session_token string not null
  • index: username, unique

users (Denormalized)

{
    "_id": "1",
    "username": "Bison",
    "first_name": "Shawn",
    "password_digest": "3489sjtkl4jts894ik5jt",
    "session_token": "384s8if4jtiowj4tsgf98u4i",
    "date_created": "5/12/2018",
    "date_updated": "7/22/2018",
    "children": [{
         "_id": "2",
         "username": "Scout",
         "first_name": "Scout"
    },{
         "_id": "3",
         "username": "Sky",
         "first_name": "Sky"
    }]
}
{
    "_id": "2",
    "username": "Scout",
    "first_name": "Scout",
    "password_digest": "3489sjtkl4jts894ik5jt",
    "session_token": "384s8if4jtiowj4tsgf98u4i",
    "date_created": "5/12/2018",
    "date_updated": "7/22/2018",
    "children": []
}
{
    "_id": "3",
    "username": "Sky",
    "first_name": "Sky",
    "password_digest": "3489sjtkl4jts894ik5jt",
    "session_token": "384s8if4jtiowj4tsgf98u4i",
    "date_created": "5/12/2018",
    "date_updated": "7/22/2018",
    "children": []
}

chores (Normalized)

Column Name Date Type Content
id integer primary key, auto increment
title string not null
body text not null
amount float not null
parent_id integer not null
child_id integer
repeating string default: one-time
deadline date
  • index: child_id, parent_id
  • Foreign Key: child_id belongs to users
  • Foreign Key: parent_id belongs to users

chores (Denormalized)

{
    "_id": "1",
    "title": "clean room",
    "body": ["make bed", "pick up toys"],
    "amount": "1.25",
    "parent": "Bison",
    "child": "Scout",
    "repeating": "daily",
    "deadline": "",
    "date_created"; "3/11/2019",
    "date_updated": "5/8/2019",
}
{
    "_id": "2",
    "title": "Do baby stuff",
    "body": ["smile", "play"],
    "amount": "0",
    "parent": "Bison",
    "child": "Sky",
    "repeating": "daily",
    "deadline": "",
    "date_created"; "3/11/2019",
    "date_updated": "5/8/2019",
}

family (Normalized)

Column Name Date Type Content
id integer primary key, auto increment
parent_id integer not null
child_id string not null
balance_owed float not null
  • index: parent_id, child_id
  • Foreign Key: parent_id belongs to users
  • Foreign Key: child_id belongs to users

family (Denormalized)

Not needed


payouts (Normalized)

Column Name Date Type Content
id integer primary key, auto increment
child_id integer not null
amount float not null
  • index: child_id
  • Foreign Key: child_id belongs to users

payouts (Denormalized)

{
    "_id": "1",
    "parent": "Bison",
    "child": "Scout",
    "amount": "5"
}
{
    "_id": "2",
    "parent": "Bison",
    "child": "Scout",
    "amount": "3.50"
}

Clone this wiki locally