title: Firebase Displaying Different Comments From The Database
body: <p>I'm creating an app in Swift similar to those of restaurant rating apps, where users post comments on different restaurants. For now, I can save successfully a user's comment to database with the below code. My app does not require a sign-up or a login screen, users can directly comment as they wish, thus I set the currentUserID as anonymous.</p>
  
  <pre><code>@IBAction func OnSubmitTouched(_ sender: UIButton) {
      if (textField.text != ""){
  
         let ref = Database.database().reference()
         let commentsReference = ref.child("comments")
         let newCommentID = commentsReference.childByAutoId().key
         let newCommentReference = commentsReference.child(newCommentID)
         // guard let currentUser = Auth.auth().currentUser else {
         //     return
         // }
          var currentUserID = "anonymous"
          if let currentUser = Auth.auth().currentUser {
                 currentUserID = currentUser.uid
          }
         // let currentUserID = currentUser.uid
          newCommentReference.setValue(["uid": currentUserID, "commentText": textField.text!]) { (error, ref) in
              if error != nil {
                  print(error!.localizedDescription)
                  return
              }
  }
  </code></pre>
  
  <p>Now, the thing is that when displaying these comments to other users, how can I separate the comments on restaurants in such a way that all restaurants don't end up having the exact same comments section? In the dashboard I could create sub-records for my comments record for every restaurant, however, there are more than 1000 restaurants in the app, it would take an enormous amount of time. Think of restaurant names as cells in a tableview, users cannot add restaurants, they can only add comments.
  I'd be very glad if someone can help me out. I know the post is a bit long but I just wanted to make sure that everything is clear. Thank you very much in advance!</p>