TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Design better databases

506 pointsby fordarnoldabout 9 years ago

32 comments

dangover 5 years ago
The original URL was <a href="http:&#x2F;&#x2F;dbpatterns.com&#x2F;" rel="nofollow">http:&#x2F;&#x2F;dbpatterns.com&#x2F;</a>, which no longer points to the right content, so we replaced it with the closest archive.org copy of the original.
mortehuabout 9 years ago
Tip for SQL users:<p>If you give all your ID fields unique names, e.g. by calling your field &quot;reservation_id&quot; instead of &quot;id&quot;, even in the reservation table, you can do stuff like:<p>SELECT * FROM reservation JOIN guest USING (reservation_id);<p>By doing &quot;USING (reservation_id)&quot; instead of &quot;ON reservation.id = guest.reservation_id&quot;, the field will be automatically deduplicated, so you don&#x27;t have to qualify it elsewhere in the query, and &quot;SELECT *&quot; will return only one copy.
评论 #11450432 未加载
评论 #11450642 未加载
评论 #11450638 未加载
评论 #11450973 未加载
评论 #11453203 未加载
评论 #11450187 未加载
评论 #11451534 未加载
评论 #11457156 未加载
评论 #11453838 未加载
评论 #11450441 未加载
评论 #11450779 未加载
评论 #11453985 未加载
评论 #11452434 未加载
评论 #11450016 未加载
clay_to_nabout 9 years ago
It&#x27;s an old-looking website, but I&#x27;ve found this site has some really cool data models: <a href="http:&#x2F;&#x2F;www.databaseanswers.org&#x2F;data_models&#x2F;index.htm" rel="nofollow">http:&#x2F;&#x2F;www.databaseanswers.org&#x2F;data_models&#x2F;index.htm</a><p>As someone in the healthcare space, looking at some of these models gives me a better idea of how various aspects of the healthcare industry work, and the things they interact with. Ex) <a href="http:&#x2F;&#x2F;www.databaseanswers.org&#x2F;data_models&#x2F;patient_data_warehouse&#x2F;index.htm" rel="nofollow">http:&#x2F;&#x2F;www.databaseanswers.org&#x2F;data_models&#x2F;patient_data_ware...</a>
评论 #11449317 未加载
评论 #11451248 未加载
评论 #11449863 未加载
评论 #11449242 未加载
评论 #11449318 未加载
klodolphabout 9 years ago
I just clicked on the second &quot;featured&quot; pattern and found this hot mess:<p><a href="http:&#x2F;&#x2F;dbpatterns.com&#x2F;documents&#x2F;5091f74289cbad03bc958bc0&#x2F;" rel="nofollow">http:&#x2F;&#x2F;dbpatterns.com&#x2F;documents&#x2F;5091f74289cbad03bc958bc0&#x2F;</a><p>It has the &quot;let&#x27;s put a UUID on every row&quot; disease common to designers who have never really learned anything other than object oriented design. Price is a string (I guess so you can put &quot;market price&quot; on the fish?), and there&#x27;s a currency symbol on every &quot;delivery&quot;. The whole thing just makes no sense. 18 stars. Unbelievable.
评论 #11449440 未加载
评论 #11449891 未加载
评论 #11450120 未加载
评论 #11453576 未加载
评论 #11449320 未加载
评论 #11449903 未加载
zenogaisabout 9 years ago
Kinda misleading title. Doesn&#x27;t really have anything to do with database design. It has to do with sharing Entity-Relationship diagrams. Maybe &quot;Design better relational models&quot;.
jordanlevabout 9 years ago
If anyone is interested, there is a 2-volume set of books called &quot;The Data Model Resource Book&quot;. They&#x27;ve been around for a while, so for more traditional businesses, but very thorough and broken out by industry:<p><a href="http:&#x2F;&#x2F;www.wiley.com&#x2F;WileyCDA&#x2F;WileyTitle&#x2F;productCd-0471380237.html" rel="nofollow">http:&#x2F;&#x2F;www.wiley.com&#x2F;WileyCDA&#x2F;WileyTitle&#x2F;productCd-047138023...</a><p><a href="http:&#x2F;&#x2F;www.wiley.com&#x2F;WileyCDA&#x2F;WileyTitle&#x2F;productCd-0471353485.html" rel="nofollow">http:&#x2F;&#x2F;www.wiley.com&#x2F;WileyCDA&#x2F;WileyTitle&#x2F;productCd-047135348...</a>
评论 #11450057 未加载
koolbaabout 9 years ago
More of an ER modeler than a database designer. The interface is pretty slick&#x2F;simple. Here&#x27;s a sample I just cooked up: <a href="http:&#x2F;&#x2F;dbpatterns.com&#x2F;documents&#x2F;570699101514b428de8893a1" rel="nofollow">http:&#x2F;&#x2F;dbpatterns.com&#x2F;documents&#x2F;570699101514b428de8893a1</a><p>I can&#x27;t imagine using it for anything real but it was fun to play with.<p>If the creator is reading this, here&#x27;s a bug report: If the user hasn&#x27;t hit &quot;Save&quot; when they export the schema, they get an empty text file and they&#x27;ll think the app is broken. It should either auto-save or prompt the user &quot;<i>You have unsaved content, do you want to save before exporting?</i>&quot;<p>UPDATE: One more bug report, the export doesn&#x27;t escape the columns names at all. It just naively adds double quotes around them. This breaks with double quotes in field names (<i>yeah yeah which is stupid but still..</i>):<p><pre><code> CREATE TABLE &quot;foo&quot; ( &quot;id&quot; int, &quot;baz&quot; varchar(255), &quot;bar&quot; varchar(255), &quot;&quot;test&quot;&quot; varchar(255) );</code></pre>
评论 #11450459 未加载
评论 #11449115 未加载
评论 #11449067 未加载
评论 #11478277 未加载
cmrdporcupineabout 9 years ago
Y&#x27;know I really miss designing relational schemas. As much as I hate SQL the language I love the relational model that it is a (butchered and ugly and compromised) implementation of. But working where I do on the systems I do now this is something I never have to deal with anymore.<p>There&#x27;s something very therapeutic about organizing data using a system of rules, and the relational data model is a powerful one.
评论 #11450704 未加载
iamleppertabout 9 years ago
Looking around I see lots of people just blindly using UUIDs for everything. At a prior job, I had a boss who forced me to use UUIDs for everything, before we had even collected a single row of data.<p>It hurts my pragmatism to solve a distributed systems problem before we even had a distributed system! Don&#x27;t be a sheep and use UUIDs, rather than a simple integer primary key or composite key that is natural to the table. People say it&#x27;s just an id, who cares? But I say people making these kinds of decisions are probably making other poor choices backed by something they read and don&#x27;t understand.<p>Here&#x27;s a great article on locality and the need for uniqueness and why UUIDs should only be introduced when needed and to solve very specific distributed systems problems. The reality is almost all applications will never need to have multiple concurrent writers.<p><a href="https:&#x2F;&#x2F;eager.io&#x2F;blog&#x2F;how-long-does-an-id-need-to-be&#x2F;?hn" rel="nofollow">https:&#x2F;&#x2F;eager.io&#x2F;blog&#x2F;how-long-does-an-id-need-to-be&#x2F;?hn</a>
评论 #11456741 未加载
gholevasabout 9 years ago
I built an electron app that allows you to design, generate, and share Mongoose Schemas if anyone finds it useful: <a href="http:&#x2F;&#x2F;mongomulch.com" rel="nofollow">http:&#x2F;&#x2F;mongomulch.com</a>
moron4hireabout 9 years ago
These schemas seem like pretty simple, straightforward adaptations of specific problems. This doesn&#x27;t actually look like any sort of actionable advice on how to design better schemas. Are we supposed to just osmose the knowledge somehow? I was expecting something more along the lines of recommendations like &quot;foreign key relationships should always be indexed, nobody ever came up with a realistic example where they shouldn&#x27;t! Why the hell isn&#x27;t this the default behavior?&quot;
igrekelabout 9 years ago
Interesting idea but it the way it is currently done isn&#x27;t that great.<p>Most of the patterns I&#x27;ve seen are obvious simple things but they are missing a lot of content like : - What was the design&#x27;s intended properties? - Expected volumes, access patterns? - Good places for indices? Maybe the comments could be of some help but really haven&#x27;t seen much. I&#x27;ve actually found more interesting content in the HN comments than on the site itself.
hgharabout 9 years ago
I don&#x27;t think this must be called &quot;patterns&quot; in computer science patterns are a model applied to give solutions to recurring problems. I was expecting something like Martin Fowler Patterns-Enterprise-Application-Architecture but for databases.<p>This should be called something like database designs.
评论 #11451017 未加载
nxzeroabout 9 years ago
One of the keys to understanding SQL, and on that note, I would highly recommend SQLZoo&#x27;s interactive tutorial that allows someone to query a (fake) database and progress using baby steps: <a href="http:&#x2F;&#x2F;sqlzoo.net" rel="nofollow">http:&#x2F;&#x2F;sqlzoo.net</a>
haddrabout 9 years ago
Cool website, for off the shelf models. For anything more advanced you should be careful, as modeling real world scenarios is rarely so abstract and mamy times you need to make some scenario-specific tradeoffs during the modeling phase to fulfill your requirements.
barryosullabout 9 years ago
Looks like they’re trying to create a repo of open source DB schemas for domains. That&#x27;s putting the cart before the horse in my mind. People don’t start with DB schemas when building domains, they end up with DB schemas after modelling them.
Scirra_Tomabout 9 years ago
Had a quick look through, don&#x27;t understand what audience this is targeted towards.
taconeabout 9 years ago
I like this site. As simple as it is, it has a lot of potential community-wise.<p>- it could allow sql exports for various platforms - it could feature an API so people can write their own framework drivers (for example creating migrations, importing existing schemas etc)<p>Lets hope that it gains users, so that the voting system (the star) can become more useful to filter out the garbage.<p>Edit: please remove the login wall to see the starred items, it raises the entry barrier quite a bit. Do you really want new visitors to see low rated schemas as the first thing?
adwfabout 9 years ago
As a database guy this makes me feel good. From looking at a lot of these schemas, my job is not going to disappear anytime soon...<p>Most egregious example for me is probably the prevalence of a lot of &quot;type&quot; tables when a simple enum column would do. Or maybe the sheer number of UUIDs that are being thrown around.<p>I even saw a circular ID chain in one. Would be fun setting up foreign key constraints for that!
raziel2pabout 9 years ago
Most of these seem extremely simple. I would like to see some examples where a good database schema isn&#x27;t so obvious.
Mister_Snugglesabout 9 years ago
When looking at an author, I can see all of their patterns. This one, in particular, has a pattern that was forked 13 times: <a href="http:&#x2F;&#x2F;dbpatterns.com&#x2F;accounts&#x2F;profile&#x2F;thaichor&#x2F;" rel="nofollow">http:&#x2F;&#x2F;dbpatterns.com&#x2F;accounts&#x2F;profile&#x2F;thaichor&#x2F;</a><p>How do you see the forks?
n13about 9 years ago
Was wondering how difficult is to code a UI like this? i.e. SVG with draggable boxes with the connections&#x2F;lines?
olalondeabout 9 years ago
Wow, that&#x27;s really cool! Would be nice to have a &quot;migration&quot; export format for Rails, Knex.js, etc.
jdc0589about 9 years ago
I was bored, so here is a quickly thrown together generic &quot;thing&quot; DB model: <a href="http:&#x2F;&#x2F;dbpatterns.com&#x2F;documents&#x2F;5706a53c1514b428de88940c" rel="nofollow">http:&#x2F;&#x2F;dbpatterns.com&#x2F;documents&#x2F;5706a53c1514b428de88940c</a>
burroxabout 9 years ago
I like it, I think there&#x27;s a real use case for it. I spent quite some time looking for examples on how to create an schema for an activity based workflow webapp.
intrasightabout 9 years ago
An empty schema diagram is to a data modeler what a blank canvas is to an artist or a blank page to a writer - thrilling but somewhat intimidating.
stevesun21about 9 years ago
I thought about the similar idea to create domain models to elaborate business rules with UML ORD rather than database ERD.
jmcgoughabout 9 years ago
The search function doesn&#x27;t seem to be working - I can&#x27;t get it to return results ever.
geniiumabout 9 years ago
Seems like a big playground...
vonklausabout 9 years ago
wow. doing my first real data model. tough to find resources like this, started literally resterday. can&#x27;t wait to check this out
whatnotestsabout 9 years ago
Kinda cool but the UX really needs some re-thinking.<p>Simple things like dialogs getting stacked on top of each other, using `prompt(&quot;...&quot;)` sometimes and modals other times, foreign key relationship arrows not indicating cardinality, etc --<p>Looks good but please don&#x27;t consider it &quot;finished&quot; yet.
gherkin0about 9 years ago
&gt; Public Newsfeed<p>&gt; jnichols created new pattern<p>&gt; Penis<p>&gt; 24 seconds ago<p>Ok... maybe they need to start with some patterns about filtering spam and noise.