Steelhacks-2023 / Lost-At-Pitt

Lost @ Pitt is a multi-platform lost-and-found tracking application, allowing users to return & reclaim lost items. Currently in development!
https://steelhacks-2023.github.io/Lost-At-Pitt/
6 stars 0 forks source link

Database improvements #39

Open tbeidlershenk opened 9 months ago

tbeidlershenk commented 9 months ago

Items should have

  1. datetime - Time submitted
  2. boolean - whether the item was successfully returned or not yet
  3. string - User UID that submitted the post

Update the PostPage UI to include 1) and 3) probably not 2) because we'll just not display the post if it's been returned Update Firebase for both dev and prod

Do we need User document storage as well to store user data? like PFP and other settings? especially once we work on user messaging and we have to store chat logs for a period of time. @jeffzheng13

tbeidlershenk commented 8 months ago

https://firebase.google.com/docs/database/flutter/structure-data https://firebase.google.com/docs/firestore/data-model

These pages might be helpful ^

tbeidlershenk commented 8 months ago

Even though Firebase is document based in a NoSQL format we are basically using it relationally because each of our collection entries follows the same format.

UPPERCASE signifies a collection lowercase is just regular data (string, timestamp, etc.) or a reference to another document

How we currently have it with my changes on lost-at-pitt-dev database:

├── USERS
│   ├── POSTS
│   │   ├── item
│   ├── first_name (string)
│   ├── last_name (string)
│   ├── location (geopoint)
├── CONVERSATIONS
│   ├── MESSAGES
│   │   ├── from (string)
│   │   ├── message (string)
│   │   ├── time_sent (timestamp)
│   ├── found_user ~ reference to document in USERS
│   ├── lost_user ~ reference to document in USERS
│   ├── item ~ reference to document in FOUND or LOST
│   ├── time_created (timestamp)
├── FOUND
│   ├── description (string)
│   ├── item_name (string)
│   ├── location (geopoint)
│   ├── phone (number)
│   ├── picture (number)
├── LOST
│   ├── description (string)
│   ├── item_name (string)
│   ├── location (geopoint)
│   ├── phone (number)
│   ├── picture (number)
└── 

However I think we should move to a Item collection in order to reduce duplication between Found and Lost. This will be useful because in the Posts collection for each user we can just reference an item in this collection.

We can use a boolean flag to signify if the item was found or lost. I didn't make these changes because existing code relies on it.

We should also remove phone because we will be implementing a chat system.

├── ITEM
│   ├── description (string)
│   ├── item_name (string)
│   ├── location (geopoint)
│   ├── picture (number)
│   ├── lost (boolean)
└── 
tbeidlershenk commented 8 months ago

40 is an extension to this - to be worked on if/when we change to one ITEM collection rather than a LOST and FOUND collection

tbeidlershenk commented 8 months ago

Accidentally closed issue, this is not completed as of yet

tbeidlershenk commented 8 months ago

Updated schema with what should be the correct naming convention at this point.

├── users
│   ├── posts
│   │   ├── item
│   ├── firstName (string)
│   ├── lastName (string)
│   ├── location (geopoint)
├── conversations
│   ├── messages
│   │   ├── from (string)
│   │   ├── message (string)
│   │   ├── timeSent (timestamp)
│   ├── foundUser ~ reference to document in USERS
│   ├── lostUser ~ reference to document in USERS
│   ├── item ~ reference to document in FOUND or LOST
│   ├── timeCreated (timestamp)
├── FOUND
│   ├── description (string)
│   ├── itemName (string)
│   ├── location (geopoint)
│   ├── phone (number)
│   ├── picture (number)
│   ├── timeCreated (timestamp)
├── lost
│   ├── description (string)
│   ├── itemName (string)
│   ├── location (geopoint)
│   ├── phone (number)
│   ├── picture (number)
│   ├── timeCreated (timestamp)
└── 
tbeidlershenk commented 7 months ago

Keeping open until we implement conversations collection as a part of Chat system