Skip to content

Data Schema

Justin Levett-Yeats edited this page Mar 28, 2017 · 31 revisions

Data Schema for Pot Lucky

Organization

The app Pot Lucky uses for its persistence layer the database platform Firebase. As Firebase uses JSON to hold data, this requires a JSON structured approach to the data schema. While this JSON object is in reality a one object with a collection of nested child objects, for the purposes of this Wiki the child components will be shown separately and organized by functional area.

An important thing to note is that Firebase uses nested objects of ID keys rather than arrays for its structure. This is to ensure data can be accessed by query strings of constructed object keys. i.e. databaseURL/userDetails/userId/{userObject}

In the code below userId, potLuckId, courseId, guestId and mealId refer to Firebase generated ID keys.

Users

// user meta data associated the with Firebase users by userId
"userDetails": {
    "userId1": {
        "firstName": "Bilbo",
        "lastName": "Baggins"
    }
},

Pot Lucks

// potLucks - origin of potLuckId and pot luck info
"potLucks": {
    "potLuckId1": {
        "userId1": true,
        "title": "Pot Luck 1",
        "theme": "The theme for our pot luck is Star Wars",
        "eventDate": "2017-03-31",
        "arriveTime": "15:00",
        "serveTime": "15:30",
        "location": "At my house, some address",
        "description": "This is the description. It's awesome.",
        "coordinates": {
                           "lat": 49.3456,
                           "lng": -123.4567
                       }
    }
},

// food for potLucks - one-to-one on potLuckId, FK on courseId, FK on usersIds
"potLuckFood": {
    "potLuckId1": {
        totalDishCount: 10,
        "APPETIZER": {
            "desiredDishCount": 3,
            "assignments": {
                "userId1": {
                    "dish": "dishName1"
                },
                "userId5": {
                    "dish": "dishName2"
                }
            }
        }
    }
},

// initial object of invited guest emails - one-to-one on potLuckId
"potLuckInvites": {
    "potLuckId1":{
        "eventDate": "2017-03-10",
        "guests": {
            "guestId1": "emailAddress1",
            "guestId2": "emailAddress2",
            "guestId3": "emailAddress3"
        }
    }
},

// confirmed guests for potLuck - one-to-one on potLuckId, FK on usersIds
"potLuckGuests": {
    "potLuckId1": {
        "userId1": {
            "inviteIssued": true,
            "inviteIssueDate": "2017-03-10",
            "inviteAccepted": false,
            "inviteAcceptedDate": null,
            "inviteDeclined": null,
            "inviteDeclinedDate": null
        },
        "userId2": {
            "inviteIssued": true,
            "inviteIssueDate": "2017-03-10",
            "inviteAccepted": true,
            "inviteAcceptedDate": "2017-03-15",
            "inviteDeclined": null,
            "inviteDeclinedDate": null
        }
    }
},

User Pot Luck list

// for getting a list of pot lucks for each user - initial scene of user pot lucks
"userPotLucks":{
    "userId1": {
        "potLuckId1": {
            "isHost": false,
            "isNew": true,
            "eventDate": "2017-04-01",
            "description": "This is the description. It's awesome.",
            "title": "Pot Luck 1"
        },
        "potLuckId2": {
            "isHost": true,
            "isNew": true,
            "eventDate: "2017-03-12",
            "description": "This is another description. It's also awesome.",
            "title": "Pot Luck 2"
        }
    },
    "userId2": {
        "potLuckId1": {
            "isHost": true,
            "isNew": false,
            "eventDate": "2017-04-01",
            "description": "This is the description. It's awesome.",
            "title": "Pot Luck 1"
        }
    }
},

Reference

Google Docs - Firebase Data Structure

Git Flow Procedures

Project Infos

Clone this wiki locally