<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Irrational Apps</title>
    <description>The latest articles on DEV Community by Irrational Apps (@irrationalapps).</description>
    <link>https://dev.clauneck.workers.dev/irrationalapps</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4000858%2F47259199-8fba-404a-88dc-9331fa083e3a.png</url>
      <title>DEV Community: Irrational Apps</title>
      <link>https://dev.clauneck.workers.dev/irrationalapps</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.clauneck.workers.dev/feed/irrationalapps"/>
    <language>en</language>
    <item>
      <title>Exception-based attendance: stop storing a row for every student who showed up</title>
      <dc:creator>Irrational Apps</dc:creator>
      <pubDate>Wed, 24 Jun 2026 18:26:34 +0000</pubDate>
      <link>https://dev.clauneck.workers.dev/irrationalapps/exception-based-attendance-stop-storing-a-row-for-every-student-who-showed-up-9c2</link>
      <guid>https://dev.clauneck.workers.dev/irrationalapps/exception-based-attendance-stop-storing-a-row-for-every-student-who-showed-up-9c2</guid>
      <description>&lt;p&gt;When you build any kind of attendance or check-in feature, the obvious data model is one row per person per session: &lt;code&gt;(session_id, student_id, status)&lt;/code&gt;. Mark everyone, store everyone. It works on day one and quietly becomes a problem by month three.&lt;/p&gt;

&lt;p&gt;For a class of 30 students meeting 20 times a month, that's 600 rows a month — and ~95% of them say the same thing: &lt;strong&gt;present&lt;/strong&gt;. You're paying storage, write cost, and UI friction to record the thing that almost always happens.&lt;/p&gt;

&lt;h2&gt;
  
  
  Model the exception, not the norm
&lt;/h2&gt;

&lt;p&gt;The fix is to flip the default. &lt;em&gt;Present&lt;/em&gt; is assumed. You only store the deviations:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Attendance exception: (session_id, student_id, status)
  where status ∈ { absent, late, excused }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Anyone enrolled in the batch for that session who has &lt;strong&gt;no&lt;/strong&gt; exception row is present. To reconstruct attendance for a session you compute:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;present(session) = roster(session.batch, session.date) − exceptions(session)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The wins are immediate:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Storage collapses.&lt;/strong&gt; Two kids skipped class? Two rows. Not thirty.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Marking is fast.&lt;/strong&gt; The tutor taps the 2 absentees instead of confirming 30 names. In practice this is the difference between a 10-second task and a tedious one nobody keeps up with.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The UI gets simpler.&lt;/strong&gt; Default state is "all present," and you only surface what changed.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The part people get wrong
&lt;/h2&gt;

&lt;p&gt;The catch is &lt;code&gt;roster(batch, date)&lt;/code&gt;. You can't just use "current members," because membership changes over time — students join mid-term, pause for a vacation, or leave. If you resolve the roster from today's membership, your historical attendance silently rewrites itself.&lt;/p&gt;

&lt;p&gt;So membership needs to be &lt;strong&gt;temporal&lt;/strong&gt;, not a boolean. Store the lifecycle:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;membership: (student_id, batch_id, joined_on, events[])
  events: [{ type: paused|resumed|left, on: date }]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now &lt;code&gt;roster(batch, date)&lt;/code&gt; means "students whose membership was active on that date" — and a student paused for February correctly drops out of February's sessions without deleting anything. Attendance from six months ago still reconstructs exactly as it happened.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why this matters even more offline-first
&lt;/h2&gt;

&lt;p&gt;I ran into this building &lt;a href="https://mentorbatch.com" rel="noopener noreferrer"&gt;Mentor Batch&lt;/a&gt;, a coaching-center manager for Indian tutors (Flutter + Firestore, offline-first so it works in areas with flaky connectivity). When your writes have to sync over a spotty connection, &lt;em&gt;not&lt;/em&gt; writing 28 redundant "present" records per session per day isn't a nice-to-have — fewer writes means less to sync, fewer conflicts, and lower Firestore cost. Modeling the exception paid off twice.&lt;/p&gt;

&lt;h2&gt;
  
  
  The same idea shows up in billing
&lt;/h2&gt;

&lt;p&gt;Once you start looking for "store the deviation, derive the norm," you see it elsewhere. Mentor Batch's fee ledger uses a cousin of this idea for payments: instead of asking the tutor to mark each month paid, you record a single lump-sum payment and &lt;strong&gt;auto-allocate it oldest-charge-first&lt;/strong&gt; across outstanding dues, generating the per-month breakdown deterministically. The source of truth is the charges and the payments; the "what's paid" view is derived. Same principle — keep the inputs minimal and canonical, compute the rest.&lt;/p&gt;

&lt;h2&gt;
  
  
  Takeaway
&lt;/h2&gt;

&lt;p&gt;Before you add a status column for every entity in every period, ask which value is the default. If one value dominates, don't store it — store the exceptions and derive the rest from a canonical, time-aware source. Your tables stay small, your writes stay cheap, and your history stays honest.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;If you run a coaching center or tutor on the side, &lt;a href="https://mentorbatch.com" rel="noopener noreferrer"&gt;Mentor Batch&lt;/a&gt; is free for up to 3 batches and 15 students (&lt;a href="https://play.google.com/store/apps/details?id=com.mentorbatch.app" rel="noopener noreferrer"&gt;Android&lt;/a&gt; or web) — but the attendance pattern above is yours to steal regardless of what you build with.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>flutter</category>
      <category>firebase</category>
      <category>database</category>
    </item>
  </channel>
</rss>
