<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="126028" data-post-id="126028">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="sreyansjain" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sreyansjain/120/16464_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  sreyansjain
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Thanks for your response.</p>
<p>I am trying to create a small feedback application where students can give feedback/rating to their teachers and need to show average feedback/rating for each teacher etc.</p>
<p>I read  <a href="https://pragprog.com/book/lhelph/functional-web-development-with-elixir-otp-and-phoenix" rel="noopener nofollow ugc">Functional Web Development with Elixir OTP, and Phoenix</a> and was wondering can this strategy be used for something which is not a game. I get the use case of the game when sometimes you just need to persist the final score/result and the running game can be managed in memory.<br>
But can we use similar strategy for apps where everything needs to be persisted permanently?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="126028" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/database-free-applications-using-files-for-storing-and-managing-state-please-critique/21957/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-126028" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="126028"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #11"></div>
  </section>
</div>
    <div class="postbit" id="126029" data-post-id="126029">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="sreyansjain" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sreyansjain/120/16464_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  sreyansjain
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="hpopp" data-post="3" data-topic="21957">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/hpopp/48/36162_2.png" class="avatar"> hpopp:</div>
<blockquote>
<p>sts in the</p>
</blockquote>
</aside>
<p>Thank you so much for sharing the practical problems you faced.<br>
Using a database gives us so many nice guarantees that we appreciate deeply when they are not available.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="126029" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/database-free-applications-using-files-for-storing-and-managing-state-please-critique/21957/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-126029" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="126029"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #12"></div>
  </section>
</div>
    <div class="postbit" id="126047" data-post-id="126047">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="peerreynders" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/peerreynders/120/5826_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  peerreynders
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="sreyansjain" data-post="12" data-topic="21957">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sreyansjain/48/16464_2.png" class="avatar"> sreyansjain:</div>
<blockquote>
<p>I am trying to create a small feedback application where students can give feedback/rating to their teachers and need to show average feedback/rating for each teacher etc.</p>
</blockquote>
</aside>
<p>At the most basic level that would only require that the individual feedback/rating submissions are persisted (preferably as structured records) to an append only file. That file can then later be processed by a separate program to aggregate the per teacher results.</p>
<p>Keeping an in memory representation of the data and processing the submissions in realtime only makes sense if all feedback submissions are made in a fairly short time period (hours to a day, rather than weeks) and there is a need to amend the displayed results as the submissions are coming in (like for an election coverage).</p>
<p>Things get a bit more interesting once you are trying ensure that all submissions are authorized and not duplicated - but again there are different ways to go about that.</p>
<p>So the priority is to identify your application’s use cases in detail - <em>not</em> which technology will be used to persist your data.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="126047" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/database-free-applications-using-files-for-storing-and-managing-state-please-critique/21957/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-126047" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="126047"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #13"></div>
  </section>
</div>
    <div class="postbit" id="126104" data-post-id="126104">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="tomekowal" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/tomekowal/120/2847_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  tomekowal
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="sreyansjain" data-post="12" data-topic="21957">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sreyansjain/48/16464_2.png" class="avatar"> sreyansjain:</div>
<blockquote>
<p>I am trying to create a small feedback application where students can give feedback/rating to their teachers and need to show average feedback/rating for each teacher etc.</p>
</blockquote>
</aside>
<p>That use case is compelling! If you have time to try, you could follow the development process like in the book:<br>
a) Write the logic for use cases like rating, querying averages and so on in pure Elixir<br>
b) Try storing the results in the <code>GenServer</code> for each teacher (similarly to having one game process)<br>
c) Figure out in the end what do you want form the storage.</p>
<p>I assume you would want to do some aggregation in the end. How many votes there were, who was the best teacher and having three entities (student, teacher and score) begs for a relational database.</p>
<p>The point of DDD is not “do not use relational database”. It is “do not pollute your logic with DB details”.  E.g. your code might model a teacher as a struct that has a list of scores. It is pure Elixir model, and your application logic does not care if it uses left join or right join or stores the scores as JSONB or whatever else you think is optimal.</p>
<p>An added benefit of starting with the in-memory model is more interactivity. Maybe you could send a push notification to a teacher when his score drops below three stars?</p>
<p>Starting from the database makes you think on the wrong level. E.g. you will need some authorisation and authentication both for teachers and students. If you start from the database, you immediately think: “should I create another users table and have foreign keys in teachers and students tables? Maybe teachers and students should be in one table and have a <code>role</code> field?”.</p>
<p>Starting from the use case, you create a struct called <code>User</code> or <code>Account</code>, implement the feature and defer retrieving the users for later. Maybe you’ll end up with getting users from LDAP or private school students database, and you won’t have to persist them at all?</p>
<p>In general, I disagree with the author of “Doing without database…”. DBs are there. They solve problems almost everyone has. Let’s use them. I agree with DDD approach of not caring about DB as long as possible.</p>
<p>Developers sometimes say stuff like: “you should abstract the database! what if you need to change it?” That happens so rarely that I would dismiss it. Abstracting database away has other benefits: your business logic gets simpler and easier to test in isolation. In case, you do a big migration, you’ve decoupled code that performs business from the code that loads stuff, and you can change only the latter without touching “business layer”.</p>
<p>TL;DR DDD=good stuff; NO_DB movement=meh</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="126104" data-batch-url="/posts/batch_likers">
                        5
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/database-free-applications-using-files-for-storing-and-managing-state-please-critique/21957/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-126104" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="126104"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #14"></div>
  </section>
</div>
    <div class="postbit" id="126145" data-post-id="126145">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="LostKobrakai" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/LostKobrakai/120/3072_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  LostKobrakai
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="tomekowal" data-post="15" data-topic="21957">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/tomekowal/48/2847_2.png" class="avatar"> tomekowal:</div>
<blockquote>
<p>That use case is compelling! If you have time to try, you could follow the development process like in the book:<br>
a) Write the logic for use cases like rating, querying averages and so on in pure Elixir<br>
b) Try storing the results in the <code>GenServer</code> for each teacher (similarly to having one game process)</p>
</blockquote>
</aside>
<p>Without c) this basically sound like what commanded allows you to do. To an extend even c), but you’d need to use either a supported eventstore or write one.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="126145" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/database-free-applications-using-files-for-storing-and-managing-state-please-critique/21957/16">Post #15</a>
	                </div>
	            </div>
              <div id="likers-container-126145" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="126145"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #15"></div>
  </section>
</div>
    <div class="postbit" id="126162" data-post-id="126162">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="gdub01" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/gdub01/120/3939_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  gdub01
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>There are 2 no db ideas that some are using… which include using a git repo to persist data and using a hosted spreadsheet service.</p>
<p>Some static site generators will read markdown and other files before compiling into a static site. NetlifyCMS is an open source project that allows people to create markdown files using a CMS… and each save is actually a git commit to master. A hook automatically rebuilds the site after each commit. So it’s great for sites that don’t change super often or sites that aren’t massive. It can include large file storage and an identity system so authors don’t need access to the git repo.</p>
<p>Second one is using a hosted spreadsheet like google sheets or airtable as the db. <a href="https://sheety.co" rel="noopener nofollow ugc">https://sheety.co</a> ← allows u to turn your google sheet into an easy api.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="126162" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/database-free-applications-using-files-for-storing-and-managing-state-please-critique/21957/17">Post #16</a>
	                </div>
	            </div>
              <div id="likers-container-126162" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="126162"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #16"></div>
  </section>
</div>
    <div class="postbit" id="126169" data-post-id="126169">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="sreyansjain" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sreyansjain/120/16464_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  sreyansjain
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="peerreynders" data-post="14" data-topic="21957">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/peerreynders/48/5826_2.png" class="avatar"> peerreynders:</div>
<blockquote>
<p>So the priority is to identify your application’s use cases in detail - <em>not</em> which technology will be used to persist your data.</p>
</blockquote>
</aside>
<p>That is insightful. Thanks.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="126169" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/database-free-applications-using-files-for-storing-and-managing-state-please-critique/21957/18">Post #17</a>
	                </div>
	            </div>
              <div id="likers-container-126169" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="126169"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #17"></div>
  </section>
</div>
    <div class="postbit" id="126192" data-post-id="126192">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="domvas" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/domvas/120/11654_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  domvas
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Maybe I’ missing the point, but nobody here is trying to NOT use a database.<br>
The first line in Wikipedia ‘database’ page is:</p>
<aside class="quote no-group">
<blockquote>
<p>A database is an organized collection of data, generally stored and accessed electronically from a computer system.</p>
</blockquote>
</aside>
<p>Then, if your application manages data, you will have a database. And as it has always been the case, the real question is “which database should I use?” and the subsidiary questions I’ve read all along this post:</p>
<ul>
<li>Do I want to rely on an external system?</li>
<li>Do I want  to use a new language for data querying?</li>
<li>What about (write / query / both) performances?</li>
<li>Do I have will / time / skills to build my own database?</li>
<li>Do I want to decouple my business logic from my storage?</li>
<li>What kind of data do I want to store?</li>
<li>Do I need to store this data?</li>
<li>Can I afford data loss?</li>
<li>What about legal? (GDPR vs append-only DB <img src="https://forum.elixirforum.com/images/emoji/apple/wink.png?v=15" title=":wink:" class="emoji" alt=":wink:" loading="lazy" width="20" height="20"> )<br>
etc.</li>
</ul>
<p>These are pure tech questions, imho and to summarize a bit fast, DDD adds another question:</p>
<ul>
<li>Do I want to express my need in a data way or a more user friendly (that even non-tech could understand) way?</li>
</ul>
<p>And ultimately, the mother of all questions is:</p>
<ul>
<li>What are my use cases?</li>
</ul>
<p>It’s strange that almost each time I read something about a DB (system or not), it tends to turn out to be some apology of this DB system against one (or all) others. All DB systems are good if they fit their use cases: you don’t use MongoDb if you care about your data, you don’t use RDBMS if you want to model a social network, you don’t use graph database to compute stats, and so on.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="126192" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/database-free-applications-using-files-for-storing-and-managing-state-please-critique/21957/19">Post #18</a>
	                </div>
	            </div>
              <div id="likers-container-126192" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="126192"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #18"></div>
  </section>
</div>
    <div class="postbit" id="126205" data-post-id="126205">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="dimitarvp" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/dimitarvp/120/38664_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  dimitarvp
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="domvas" data-post="19" data-topic="21957">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/domvas/48/11654_2.png" class="avatar"> domvas:</div>
<blockquote>
<p>These are pure tech questions</p>
</blockquote>
</aside>
<p>Like half the points you enumerated are political or, at least, are not decided by the programmers writing the code on the ground. They are decided by at least team leaders, more likely CTOs.</p>
<p>As for DB-vs-DB: there are unquestionable benefits of using one DB as opposed to another but that’s a huge  topic on its own.</p>
<p>As for “should we even use a DB” – this discussion is not monopolized at all. But most people naturally come to the conclusion that the DB helps.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="126205" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/database-free-applications-using-files-for-storing-and-managing-state-please-critique/21957/20">Post #19</a>
	                </div>
	            </div>
              <div id="likers-container-126205" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="126205"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-last-post cat-last-post" title="Last post!"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>