Suggestions on structuring Firebase JSON tree

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
0
down vote

favorite












I'm in the process of creating a simple registration system for my school district using Firebase as the database. I need two things for the client: the list of available courses and the courses a user has registered for.



Following the Firebase documentation, I'm trying to keep my tree as flat as possible (full example below). I've set up an index of courses and a user index. I write registrations to both at the same time.




courses: // index all the courses available
key1:
title: "Course 1",
desc: "This is a description string.",
date: 2018-01-01 12:00:00Z
members:
user1: true
...

,
key2 ... ,
,
users: // track individual user registrations
user1:
key1: true,
...
,
user2: ...




I'm having a hard time getting the client to display user registrations because I'm trying to reference the courses index via key. I'm thinking my JSON structure needs to change, but I'm not entirely sure how to do that without too much nesting or repetition (and it's possible I'm overthinking this).



Would it make more sense to do something like this in the users index rather than trying to reference back and forth?



users: // track individual user registrations with full details
user1:
key1:
title: "Course 1",
date: "2018-01-01 12:00:00Z"
,
key2: ...
,
user2: ...







share|improve this question

























    up vote
    0
    down vote

    favorite












    I'm in the process of creating a simple registration system for my school district using Firebase as the database. I need two things for the client: the list of available courses and the courses a user has registered for.



    Following the Firebase documentation, I'm trying to keep my tree as flat as possible (full example below). I've set up an index of courses and a user index. I write registrations to both at the same time.




    courses: // index all the courses available
    key1:
    title: "Course 1",
    desc: "This is a description string.",
    date: 2018-01-01 12:00:00Z
    members:
    user1: true
    ...

    ,
    key2 ... ,
    ,
    users: // track individual user registrations
    user1:
    key1: true,
    ...
    ,
    user2: ...




    I'm having a hard time getting the client to display user registrations because I'm trying to reference the courses index via key. I'm thinking my JSON structure needs to change, but I'm not entirely sure how to do that without too much nesting or repetition (and it's possible I'm overthinking this).



    Would it make more sense to do something like this in the users index rather than trying to reference back and forth?



    users: // track individual user registrations with full details
    user1:
    key1:
    title: "Course 1",
    date: "2018-01-01 12:00:00Z"
    ,
    key2: ...
    ,
    user2: ...







    share|improve this question





















      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I'm in the process of creating a simple registration system for my school district using Firebase as the database. I need two things for the client: the list of available courses and the courses a user has registered for.



      Following the Firebase documentation, I'm trying to keep my tree as flat as possible (full example below). I've set up an index of courses and a user index. I write registrations to both at the same time.




      courses: // index all the courses available
      key1:
      title: "Course 1",
      desc: "This is a description string.",
      date: 2018-01-01 12:00:00Z
      members:
      user1: true
      ...

      ,
      key2 ... ,
      ,
      users: // track individual user registrations
      user1:
      key1: true,
      ...
      ,
      user2: ...




      I'm having a hard time getting the client to display user registrations because I'm trying to reference the courses index via key. I'm thinking my JSON structure needs to change, but I'm not entirely sure how to do that without too much nesting or repetition (and it's possible I'm overthinking this).



      Would it make more sense to do something like this in the users index rather than trying to reference back and forth?



      users: // track individual user registrations with full details
      user1:
      key1:
      title: "Course 1",
      date: "2018-01-01 12:00:00Z"
      ,
      key2: ...
      ,
      user2: ...







      share|improve this question











      I'm in the process of creating a simple registration system for my school district using Firebase as the database. I need two things for the client: the list of available courses and the courses a user has registered for.



      Following the Firebase documentation, I'm trying to keep my tree as flat as possible (full example below). I've set up an index of courses and a user index. I write registrations to both at the same time.




      courses: // index all the courses available
      key1:
      title: "Course 1",
      desc: "This is a description string.",
      date: 2018-01-01 12:00:00Z
      members:
      user1: true
      ...

      ,
      key2 ... ,
      ,
      users: // track individual user registrations
      user1:
      key1: true,
      ...
      ,
      user2: ...




      I'm having a hard time getting the client to display user registrations because I'm trying to reference the courses index via key. I'm thinking my JSON structure needs to change, but I'm not entirely sure how to do that without too much nesting or repetition (and it's possible I'm overthinking this).



      Would it make more sense to do something like this in the users index rather than trying to reference back and forth?



      users: // track individual user registrations with full details
      user1:
      key1:
      title: "Course 1",
      date: "2018-01-01 12:00:00Z"
      ,
      key2: ...
      ,
      user2: ...









      share|improve this question










      share|improve this question




      share|improve this question









      asked Jan 25 at 15:15









      Brian

      1064




      1064

























          active

          oldest

          votes











          Your Answer




          StackExchange.ifUsing("editor", function ()
          return StackExchange.using("mathjaxEditing", function ()
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
          );
          );
          , "mathjax-editing");

          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "196"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );








           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f185976%2fsuggestions-on-structuring-firebase-json-tree%23new-answer', 'question_page');

          );

          Post as a guest



































          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes










           

          draft saved


          draft discarded


























           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f185976%2fsuggestions-on-structuring-firebase-json-tree%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          Chat program with C++ and SFML

          Function to Return a JSON Like Objects Using VBA Collections and Arrays

          Will my employers contract hold up in court?