<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[#RubyOnRails database and app design question in the vicinity of inventory management:]]></title><description><![CDATA[<p><a href="https://social.lol/tags/RubyOnRails" rel="tag">#<span>RubyOnRails</span></a> database and app design question in the vicinity of inventory management:</p><p>• Your app has a Warehouse model,<br />• a serialized InventoryItem model, and<br />• a SKU model</p><p>An InventoryItem belongs to a SKU and belongs to a Warehouse. Over time, InventoryItems move between Warehouses but the association to a SKU is static.</p><p>Out there in the real world, you're managing inventory at multiple locations •and• need to know precisely which InventoryItems (based on serial numbers) are in which Warehouses.</p><p>How would you design an efficient means of tracking not only which InventoryItems are in which Warehouse (fairly easy with associations) but also tracking the •count• of each SKU at each Warehouse?</p><p>So, something a bit more complicated (as far as I can think about it, at least) than a typical `belongs_to` and `counter_cache` setup.</p>]]></description><link>https://board.circlewithadot.net/topic/7d03ce1a-84b2-411b-b295-1f79a8bca02b/rubyonrails-database-and-app-design-question-in-the-vicinity-of-inventory-management</link><generator>RSS for Node</generator><lastBuildDate>Mon, 25 May 2026 07:39:32 GMT</lastBuildDate><atom:link href="https://board.circlewithadot.net/topic/7d03ce1a-84b2-411b-b295-1f79a8bca02b.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 20 May 2026 19:03:42 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to #RubyOnRails database and app design question in the vicinity of inventory management: on Thu, 21 May 2026 14:43:36 GMT]]></title><description><![CDATA[<p><span><a href="/user/jgarber%40social.lol" rel="nofollow noopener">@<span>jgarber</span></a></span> if that’s too slow see if you can add some indices, if still slow wrap Rails.cache around it.</p>]]></description><link>https://board.circlewithadot.net/post/https://status.pointless.one/users/pointlessone/statuses/116613094841285213</link><guid isPermaLink="true">https://board.circlewithadot.net/post/https://status.pointless.one/users/pointlessone/statuses/116613094841285213</guid><dc:creator><![CDATA[pointlessone@status.pointless.one]]></dc:creator><pubDate>Thu, 21 May 2026 14:43:36 GMT</pubDate></item><item><title><![CDATA[Reply to #RubyOnRails database and app design question in the vicinity of inventory management: on Thu, 21 May 2026 14:36:47 GMT]]></title><description><![CDATA[<p><span><a href="/user/pointlessone%40status.pointless.one">@<span>pointlessone</span></a></span> Nope, I don't think you're missing anything!</p>]]></description><link>https://board.circlewithadot.net/post/https://social.lol/ap/users/115781919729724887/statuses/116613068057905088</link><guid isPermaLink="true">https://board.circlewithadot.net/post/https://social.lol/ap/users/115781919729724887/statuses/116613068057905088</guid><dc:creator><![CDATA[jgarber@social.lol]]></dc:creator><pubDate>Thu, 21 May 2026 14:36:47 GMT</pubDate></item><item><title><![CDATA[Reply to #RubyOnRails database and app design question in the vicinity of inventory management: on Thu, 21 May 2026 14:30:22 GMT]]></title><description><![CDATA[<p><span><a href="/user/jgarber%40social.lol" rel="nofollow noopener">@<span>jgarber</span></a></span> I feel like I’m missing something. SKU is a type of thing, InventoryItem is a thing, and Warehouse is a place.</p><p>So to count thing you do select count(id) from inventory_items group by warehouse, sku.</p><p>Or did I read that completely wrong?</p>]]></description><link>https://board.circlewithadot.net/post/https://status.pointless.one/users/pointlessone/statuses/116613042814639611</link><guid isPermaLink="true">https://board.circlewithadot.net/post/https://status.pointless.one/users/pointlessone/statuses/116613042814639611</guid><dc:creator><![CDATA[pointlessone@status.pointless.one]]></dc:creator><pubDate>Thu, 21 May 2026 14:30:22 GMT</pubDate></item><item><title><![CDATA[Reply to #RubyOnRails database and app design question in the vicinity of inventory management: on Wed, 20 May 2026 23:48:02 GMT]]></title><description><![CDATA[<p><span><a href="/user/jgarber%40social.lol">@<span>jgarber</span></a></span> just takes one update in db console and your counts are off <img src="https://board.circlewithadot.net/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=28325c671da" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:23px;width:auto;vertical-align:middle" title=":)" alt="🙂" /></p>]]></description><link>https://board.circlewithadot.net/post/https://ruby.social/users/davetron5000/statuses/116609573372669130</link><guid isPermaLink="true">https://board.circlewithadot.net/post/https://ruby.social/users/davetron5000/statuses/116609573372669130</guid><dc:creator><![CDATA[davetron5000@ruby.social]]></dc:creator><pubDate>Wed, 20 May 2026 23:48:02 GMT</pubDate></item><item><title><![CDATA[Reply to #RubyOnRails database and app design question in the vicinity of inventory management: on Wed, 20 May 2026 23:21:36 GMT]]></title><description><![CDATA[<p><span><a href="/user/davetron5000%40ruby.social">@<span>davetron5000</span></a></span> You know, that’s a good call out that’s got me thinking: How “real time” does my app’s statistical data (inventory counts at locations, etc.) really need to be?</p><p>Rhetorical in this conversation, but something for me to consider with the folks at work tomorrow.</p><p>On your last point: I actually don’t mind counter caches! I haven’t (yet) gotten bitten by one on an association but that could be a consequence of the small scale I’m operating at. Or, I’ve missed some problems. <img src="https://board.circlewithadot.net/assets/plugins/nodebb-plugin-emoji/emoji/android/1f602.png?v=28325c671da" class="not-responsive emoji emoji-android emoji--joy" style="height:23px;width:auto;vertical-align:middle" title="😂" alt="😂" /></p>]]></description><link>https://board.circlewithadot.net/post/https://social.lol/ap/users/115781919729724887/statuses/116609469410319192</link><guid isPermaLink="true">https://board.circlewithadot.net/post/https://social.lol/ap/users/115781919729724887/statuses/116609469410319192</guid><dc:creator><![CDATA[jgarber@social.lol]]></dc:creator><pubDate>Wed, 20 May 2026 23:21:36 GMT</pubDate></item><item><title><![CDATA[Reply to #RubyOnRails database and app design question in the vicinity of inventory management: on Wed, 20 May 2026 23:10:19 GMT]]></title><description><![CDATA[<p><span><a href="/user/jgarber%40social.lol">@<span>jgarber</span></a></span> Yeah, the last place I worked was at a tiny scale, but I still put non-normalized data into separate tables.  Maybe more infra than you want, but I had migrations for reporting tables + models in the rails app, and then regular tasks to query the normalized data and populate the reporting stuff.  Even in that case, the reporting was needed at most daily, so again realtime was not a factor.</p><p>I just balk at the rails "auto update some count" thing because how could you ever trust it?</p>]]></description><link>https://board.circlewithadot.net/post/https://ruby.social/users/davetron5000/statuses/116609425033411032</link><guid isPermaLink="true">https://board.circlewithadot.net/post/https://ruby.social/users/davetron5000/statuses/116609425033411032</guid><dc:creator><![CDATA[davetron5000@ruby.social]]></dc:creator><pubDate>Wed, 20 May 2026 23:10:19 GMT</pubDate></item><item><title><![CDATA[Reply to #RubyOnRails database and app design question in the vicinity of inventory management: on Wed, 20 May 2026 21:48:01 GMT]]></title><description><![CDATA[<p><span><a href="/user/davetron5000%40ruby.social">@<span>davetron5000</span></a></span> The app I'm working on operates at a fraction of a fraction of a percent of the scale of StitchFix. <img src="https://board.circlewithadot.net/assets/plugins/nodebb-plugin-emoji/emoji/android/1f605.png?v=28325c671da" class="not-responsive emoji emoji-android emoji--sweat_smile" style="height:23px;width:auto;vertical-align:middle" title="😅" alt="😅" /></p><p>Strictly internal app for managing serialized inventory between various locations out there in the real world and making sure we restock depending on configured conditions, contractual obligations, etc.</p><p>So, in this case at least, the reporting aspect (knowing how much inventory is where and when) is part of the core function.</p><p>There's also a bunch of knock-on data-related tasks that the team's pulling out from a replica database and using some off-the-shelf dashboard kind of thing. I tend not to have much to do with that, though.</p>]]></description><link>https://board.circlewithadot.net/post/https://social.lol/ap/users/115781919729724887/statuses/116609101414346073</link><guid isPermaLink="true">https://board.circlewithadot.net/post/https://social.lol/ap/users/115781919729724887/statuses/116609101414346073</guid><dc:creator><![CDATA[jgarber@social.lol]]></dc:creator><pubDate>Wed, 20 May 2026 21:48:01 GMT</pubDate></item><item><title><![CDATA[Reply to #RubyOnRails database and app design question in the vicinity of inventory management: on Wed, 20 May 2026 21:44:34 GMT]]></title><description><![CDATA[<p><span><a href="/user/jgarber%40social.lol">@<span>jgarber</span></a></span> stitch fix had this exact model and we counted items per SKU when needed. The primary DB did not have reporting data cached on it. So a count of items in a SKU per warehouse was not modeled in Rails explicitly. </p><p>Transactional logic in our case never needed to know the counts. Only reporting and that was not needed realtime. </p><p>Much of our complex transactional queries were in SQL-way easier to understand and maintain than Active Record.</p>]]></description><link>https://board.circlewithadot.net/post/https://ruby.social/users/davetron5000/statuses/116609087883193650</link><guid isPermaLink="true">https://board.circlewithadot.net/post/https://ruby.social/users/davetron5000/statuses/116609087883193650</guid><dc:creator><![CDATA[davetron5000@ruby.social]]></dc:creator><pubDate>Wed, 20 May 2026 21:44:34 GMT</pubDate></item><item><title><![CDATA[Reply to #RubyOnRails database and app design question in the vicinity of inventory management: on Wed, 20 May 2026 20:15:33 GMT]]></title><description><![CDATA[<p><span><a href="/user/sstephenson%40indieweb.social">@<span>sstephenson</span></a></span> It was right in front of me the whole time!</p><p>Appreciate your feedback on this one.</p><p>I’m responsible for an app that’s growing beyond its initial and rudimentary data model. I’m beginning to see a path out of the current problems, but it’ll involve some tricky data migrations in addition to the foundational modeling improvements.</p>]]></description><link>https://board.circlewithadot.net/post/https://social.lol/ap/users/115781919729724887/statuses/116608737837031835</link><guid isPermaLink="true">https://board.circlewithadot.net/post/https://social.lol/ap/users/115781919729724887/statuses/116608737837031835</guid><dc:creator><![CDATA[jgarber@social.lol]]></dc:creator><pubDate>Wed, 20 May 2026 20:15:33 GMT</pubDate></item><item><title><![CDATA[Reply to #RubyOnRails database and app design question in the vicinity of inventory management: on Wed, 20 May 2026 20:11:44 GMT]]></title><description><![CDATA[<p><span><a href="/user/jgarber%40social.lol">@<span>jgarber</span></a></span> yeah, I like that, nice parity</p>]]></description><link>https://board.circlewithadot.net/post/https://indieweb.social/users/sstephenson/statuses/116608722824712329</link><guid isPermaLink="true">https://board.circlewithadot.net/post/https://indieweb.social/users/sstephenson/statuses/116608722824712329</guid><dc:creator><![CDATA[sstephenson@indieweb.social]]></dc:creator><pubDate>Wed, 20 May 2026 20:11:44 GMT</pubDate></item><item><title><![CDATA[Reply to #RubyOnRails database and app design question in the vicinity of inventory management: on Wed, 20 May 2026 19:55:54 GMT]]></title><description><![CDATA[<p><span><a href="/user/sstephenson%40indieweb.social">@<span>sstephenson</span></a></span> There’s a related model I didn’t mention, RestockingLevel, whose most useful attribute is minimum allowable quantity for a particular SKU at a particular Warehouse.</p><p>It’s closely related to what I outlined in the problem statement, but isn’t exactly the same. Its utility is more in triggering action when certain conditions are met.</p><p>So maybe “StockLevel” for this new join model…? <img src="https://board.circlewithadot.net/assets/plugins/nodebb-plugin-emoji/emoji/android/1f914.png?v=28325c671da" class="not-responsive emoji emoji-android emoji--thinking_face" style="height:23px;width:auto;vertical-align:middle" title="🤔" alt="🤔" /></p>]]></description><link>https://board.circlewithadot.net/post/https://social.lol/ap/users/115781919729724887/statuses/116608660581209153</link><guid isPermaLink="true">https://board.circlewithadot.net/post/https://social.lol/ap/users/115781919729724887/statuses/116608660581209153</guid><dc:creator><![CDATA[jgarber@social.lol]]></dc:creator><pubDate>Wed, 20 May 2026 19:55:54 GMT</pubDate></item><item><title><![CDATA[Reply to #RubyOnRails database and app design question in the vicinity of inventory management: on Wed, 20 May 2026 19:51:36 GMT]]></title><description><![CDATA[<p><span><a href="/user/davetron5000%40ruby.social">@<span>davetron5000</span></a></span></p><p>“should SKU belong to a warehouse?”</p><p>I don’t believe so, no. SKU here would be for categorization and reporting, as you noted.</p>]]></description><link>https://board.circlewithadot.net/post/https://social.lol/ap/users/115781919729724887/statuses/116608643686334203</link><guid isPermaLink="true">https://board.circlewithadot.net/post/https://social.lol/ap/users/115781919729724887/statuses/116608643686334203</guid><dc:creator><![CDATA[jgarber@social.lol]]></dc:creator><pubDate>Wed, 20 May 2026 19:51:36 GMT</pubDate></item><item><title><![CDATA[Reply to #RubyOnRails database and app design question in the vicinity of inventory management: on Wed, 20 May 2026 19:46:42 GMT]]></title><description><![CDATA[<p><span><a href="/user/jgarber%40social.lol">@<span>jgarber</span></a></span> maybe there’s an associated physical process you can reference? could something like “Stock” work?</p><p>my other tips are to make sure to include timestamp columns, because you will probably want them for some reason or another, and don’t forget your indexes</p><p>(also, InventoryAllocation isn’t bad!)</p>]]></description><link>https://board.circlewithadot.net/post/https://indieweb.social/users/sstephenson/statuses/116608624371771402</link><guid isPermaLink="true">https://board.circlewithadot.net/post/https://indieweb.social/users/sstephenson/statuses/116608624371771402</guid><dc:creator><![CDATA[sstephenson@indieweb.social]]></dc:creator><pubDate>Wed, 20 May 2026 19:46:42 GMT</pubDate></item><item><title><![CDATA[Reply to #RubyOnRails database and app design question in the vicinity of inventory management: on Wed, 20 May 2026 19:45:10 GMT]]></title><description><![CDATA[<p><span><a href="/user/jgarber%40social.lol">@<span>jgarber</span></a></span> should SKU belong to a warehouse? If InventoryItem represents a single physical thing, THAT belongs to a warehouse so you know where it is. It has a SKU so for categorization and reporting, but a SKU and warehouse should only relate through items.</p>]]></description><link>https://board.circlewithadot.net/post/https://ruby.social/users/davetron5000/statuses/116608618377312698</link><guid isPermaLink="true">https://board.circlewithadot.net/post/https://ruby.social/users/davetron5000/statuses/116608618377312698</guid><dc:creator><![CDATA[davetron5000@ruby.social]]></dc:creator><pubDate>Wed, 20 May 2026 19:45:10 GMT</pubDate></item><item><title><![CDATA[Reply to #RubyOnRails database and app design question in the vicinity of inventory management: on Wed, 20 May 2026 19:29:11 GMT]]></title><description><![CDATA[<p><span><a href="/user/sstephenson%40indieweb.social">@<span>sstephenson</span></a></span> “InventoryAllocation”…?</p>]]></description><link>https://board.circlewithadot.net/post/https://social.lol/ap/users/115781919729724887/statuses/116608555491050609</link><guid isPermaLink="true">https://board.circlewithadot.net/post/https://social.lol/ap/users/115781919729724887/statuses/116608555491050609</guid><dc:creator><![CDATA[jgarber@social.lol]]></dc:creator><pubDate>Wed, 20 May 2026 19:29:11 GMT</pubDate></item><item><title><![CDATA[Reply to #RubyOnRails database and app design question in the vicinity of inventory management: on Wed, 20 May 2026 19:28:44 GMT]]></title><description><![CDATA[<p><span><a href="/user/sstephenson%40indieweb.social">@<span>sstephenson</span></a></span> The naming conundrum is ruining me!</p>]]></description><link>https://board.circlewithadot.net/post/https://social.lol/ap/users/115781919729724887/statuses/116608553746598916</link><guid isPermaLink="true">https://board.circlewithadot.net/post/https://social.lol/ap/users/115781919729724887/statuses/116608553746598916</guid><dc:creator><![CDATA[jgarber@social.lol]]></dc:creator><pubDate>Wed, 20 May 2026 19:28:44 GMT</pubDate></item><item><title><![CDATA[Reply to #RubyOnRails database and app design question in the vicinity of inventory management: on Wed, 20 May 2026 19:24:59 GMT]]></title><description><![CDATA[<p><span><a href="/user/jgarber%40social.lol">@<span>jgarber</span></a></span> I would absolutely use a join model for this (and spend some time coming up with a good name for it)</p>]]></description><link>https://board.circlewithadot.net/post/https://indieweb.social/users/sstephenson/statuses/116608538986447243</link><guid isPermaLink="true">https://board.circlewithadot.net/post/https://indieweb.social/users/sstephenson/statuses/116608538986447243</guid><dc:creator><![CDATA[sstephenson@indieweb.social]]></dc:creator><pubDate>Wed, 20 May 2026 19:24:59 GMT</pubDate></item><item><title><![CDATA[Reply to #RubyOnRails database and app design question in the vicinity of inventory management: on Wed, 20 May 2026 19:08:24 GMT]]></title><description><![CDATA[<p>I don't know of a "polymorphic counter cache" kind of thing.</p><p>A JSONB column on the Warehouse model also feels less-than-ideal.</p><p>A join model between the Warehouse and InventoryItems models is an approach. The counter cache could be on the join model. That'd still involve including/joining the join model when the app wants to display inventory counts along with a Warehouse but would also avoid manually fiddling with counters as InventoryItems move from Warehouse to Warehouse.</p>]]></description><link>https://board.circlewithadot.net/post/https://social.lol/ap/users/115781919729724887/statuses/116608473795145595</link><guid isPermaLink="true">https://board.circlewithadot.net/post/https://social.lol/ap/users/115781919729724887/statuses/116608473795145595</guid><dc:creator><![CDATA[jgarber@social.lol]]></dc:creator><pubDate>Wed, 20 May 2026 19:08:24 GMT</pubDate></item></channel></rss>