title: Firebase Real Time Database .child vs .reference - plus .database()
body: <p>Firebase documentation says we can have up to 200k connection limit per database,<br />
  <a href="https://i.stack.imgur.com/PG8xi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PG8xi.png" alt="enter image description here" /></a></p>
  <p>Because we can have several references of that database in the project, I couldn't clearly understand what counts as a connection?</p>
  <pre><code>struct DatabaseService { // class ?
     let db = Database.database()
     let ref = db.reference(&quot;/path&quot;)
     let child = db.reference().child(&quot;/path&quot;)
     // what is the difference between ref and child? If no difference why do we have both of them?
     let db2 = Database.database()
     let ref2 = db2.reference()
     // db and db2 counts as one connection or two ?
     func observeRef() {
        ref.observe(.value) { snap in print(&quot;called&quot;) }
     }
     func observeRef2() {
        ref2.observe(.value) { snap in print(&quot;called&quot;) }
     }
     func removeAllObservers() {
        ref.removeAllObservers() // will this also remove ref2.observe?
     }
  }
  </code></pre>
  <p>Should we create one database service class share its reference across app as singleton or is it okay to create a that service as a struct and create it whenever you need across the app?
  Will having one instance or having structs affect our database connection count?</p>