Skip to content
TheChatArchiveThe Chat Archive
gpt-4-0314· openaiHugging Face Suzhen/CodeChat

I have now finished a prt of the front-end and for me to continue I need some sort of…

  1. User

    I have now finished a prt of the front-end and for me to continue I need some sort of backend. So I was thinking of the following data schema. What do you think? What should I change for long term use and scalability? Should I change names of the documents or collections? How can I make it better.

    Users (collection) (document) Main (collection) (document) {jobInformation} (fields) (document) {jobInformation} (fields) etc. Signup (collection) Information (document) {UserInformation} (fields) (document) Main (collection) (document) {jobInformation} (fields) (document) {jobInformation} (fields) etc. Signup (collection) Information (document) {UserInformation} (fields) etc.

    Aggregation (collection) Jobs (document) (field (type map)) {jobInfo} (field (type map)) {jobInfo} etc. Pharmacists (document) (field (type map)) {userInfo} (field (type map)) {userInfo} etc. pharmacyAssistant ((document) consists of both pharmacy tech and assistant users) (field (type map)) {userInfo} (field (type map)) {userInfo} etc.

  2. Assistant

    Overall, the data schema seems to have a good structure for organizing user-related data. However, some adjustments could be made to improve the long-term use and scalability. Below are some recommendations:

    1. Naming conventions: Use singular names for collections/documents and use camelCase for field names.

      users (collection)
        <userId> (document)
          jobs (collection)
            <jobId> (document)
              {jobInformation} (fields)
            <jobId> (document)
              {jobInformation} (fields)
          profile (collection)
            personalInfo (document)
              {userInformation} (fields)
      
      aggregations (collection)
        jobList (document)
          <jobId> (field (type map))
            {jobInfo}
        pharmacistList (document)
          <userId> (field (type map))
            {userInfo}
        pharmacyAssistantList (document)
          <userId> (field (type map))
            {userInfo}
      
    2. Consider storing the user's personal information directly as fields in the user document, instead of inside a collection and document.

      users (collection)
        <userId> (document)
          {userInformation} (fields)
          jobs (collection)
            <jobId> (document)
              {jobInformation} (fields)
      
    3. Instead of having separate documents for different types of users within the "aggregations" collection, you can have a single collection called "userLists" that stores all user types' information as fields. Then, use an array to store the userIDs instead of using a map field type.

      aggregations (collection)
        userLists (document)
          jobList (field (type array)) - Array of jobIDs
          pharmacistList (field (type array)) - Array of pharmacist userIDs
          pharmacyAssistantList (field (type array)) - Array of pharmacy tech/assistant userIDs
      
    4. If you expect a large number of job entries, consider flattening the structure to avoid nesting too many subcollections beneath users. Instead, store job information in a separate "jobs" collection and use references (e.g., jobID) to associate jobs with users.

      users (collection)
        <userId> (document)
          {userInformation} (fields)
      
      jobs (collection)
        <jobId> (document)
          {jobInformation} (fields)
          userId (field - reference to the user who created the job)
      

    By implementing the suggested changes, you would set a more robust foundation for long-term use and increased scalability of your application.

  3. User

    If I did number 2, how will that help, and is it s good idea in terms of retreiving data and all?

  4. Assistant

    Storing the user's personal information directly as fields in the user document (suggestion #2) can have several advantages:

    1. Easier data retrieval: When you want to retrieve a user's personal information, you only need to query the specific user document without having to navigate through additional collections or documents. This can make data retrieval simpler and potentially faster.

    2. Less complex data structure: By reducing the number of nested collections and documents, the data structure becomes less complex, making it easier to understand and manage. A less complex data structure can also lead to fewer possibilities for errors when performing database operations.

    3. Reduced document reads: In Firestore, you are charged based on the number of document reads. By consolidating relevant user information in the user document, you are reducing the number of documents that need to be read when fetching user data, ultimately saving on costs.

    However, it's essential to consider Firestore's imposed limitations on the size of a single document which is 1 MiB. If the user's personal information is vast and there's a likelihood of exceeding this limit, then storing that information in a separate document within a subcollection (as in your original schema) might be a better solution. If this is not a concern, consolidating user information in the user document can be beneficial for data retrieval and simplicity.

    In summary, storing user information directly as fields in the user document can be a good idea in terms of data retrieval and maintaining a simple data structure, as long as the document size does not exceed the imposed limitation by Firestore.

  5. User

    What is the latest data you have?

  6. Assistant

    As an AI language model, I don't have real-time access to any specific data. My knowledge is based on the pre-existing information fed into me, which is most up-to-date until September 2021. If you have any questions or need information within that timeframe, feel free to ask, and I'll do my best to assist you. For real-time or more recent information, please refer to appropriate and reliable sources like official websites, databases, or news outlets.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.