Live data from Hacker News

Ask HN: What are some examples of good database schema designs?

news.ycombinator.com

61–70 of 181 posts

Re: Ask HN: What are some examples of good database schema designs?

#61

> When I read about database schemas with thousands of tables I wonder what kind of problem could possibly require so many tables. Businesses that trade in thousands of products, employ thousands of people in dozens of countries, with hundreds of different taxation, human relations, timekeeping, payroll, health insurance and retirement savings laws, dozens of sites, inventories in hundreds of locations managed by doz…

or the systems arent multi-tenant so they end up cloning the schema for each customer

Re: Ask HN: What are some examples of good database schema designs?

#62
post #45

Earlier quoted context omitted.

I disagree with pretty much everything you said. :) I think there are plenty of bad ORMs and there are plenty of ways to use the good ones in a bad way, but that doesn’t mean that they aren’t providing the value I mentioned. For instance Entity Framework Core with code-first migrations has you designing the data models themselves, then wiring up relationships and other metadata (indexes, keys, etc.) in the DB context…

It's well-known to be a topic that splits opinion, so I'm not surprised we disagree :) To me, "designing the data model", "wiring up relationships", etc doesn't require an ORM. On the other hand, I do agree it's good to have some tooling around it and that's something many more bare-bones frameworks (ORM or not) are lacking. I don't hear people talk about "coding for the web, but design so that you can easily switch…

> It seems to me databases are uniquely treated this way, as some kind of disposable, simple piece of side equipment

This is exactly right - lots of people are still cargo-culting rules of thumb that no longer make any sense.

This was an artifact of the last generation's commercial DB market. Open source DBs weren't "there" yet; a combination of real limitations and risk-conservatism kept companies shoveling huge amounts of money at vendors for features and stability now provided by `apt-get install postgresql-server`.

If you just lit seven figures on fire for a database license, you're not hungry to do it again, so you wanted all your software to be compatible with whichever vendor you just locked yourself in to. And certain DB vendors are very well known for brass-knuckle negotiation; if you could credibly threaten to migrate to $competition instead of upgrading, it was one of the few actually useful negotiating levers available.

Today, open source DBs are better than the commercial ones in many situations, certainly not worse in general use, and the costs of running a bunch of different ones are far lower. Not to mention, the best way to win a software audit is to run zero instances of something.

Re: Ask HN: What are some examples of good database schema designs?

#63
it really all depends on the requirements.

i use to think wordpress had the worst schema in the world. after actually using it and writing plugins for it, i've come to the conclusion that it is genius. their schema design really makes it very easy for others to "extend" the structure without having to actually alter the schema.

to elaborate on what i mean by extend, wordpress's schema is basically a post table that has the very minimal required columns for creating a post (like the title, date, status and a couple of other), the post_meta table references that post table and basically is used like a huge key/value store. really all it is post_id column (which reference back to the posts table), a key column and a value column. You can add whatever you want to a post by adding them to the post_meta.

this design is copied for all other areas as well, such as users, comments and what have you.

https://codex.wordpress.org/Database_Description

now obviously this kind of design isn't going to work for something like a financial institution where you most likely want a ton of referential integrity built into the schema to prevent accidental data lost and to validate data input, but for a CMS it works very well.

again... it all depends on what the system requirements are.

Re: Ask HN: What are some examples of good database schema designs?

#65

it really all depends on the requirements. i use to think wordpress had the worst schema in the world. after actually using it and writing plugins for it, i've come to the conclusion that it is genius. their schema design really makes it very easy for others to "extend" the structure without having to actually alter the schema. to elaborate on what i mean by extend, wordpress's schema is basically a post table that h…

After searching for years for what that design was called, I finally read somewhere that it’s the “property bag pattern”. Seemed fitting.

Re: Ask HN: What are some examples of good database schema designs?

#66
When you think about large enterprise software systems with screen after screen full of data entry forms, with drop down lists everywhere, every single one of those drop down selectors is likely a database table. Every schema like that will have a mix of large tables (customers, products, etc) and lots of small tables.

I don’t think there’s a number above which you should not go, it’s really about how the data is organized and how easy it is to get data in and out of. I agree with another comment here about looking at anti-patterns first. There are some common ones that would be red flags.

As an example of what not to do: I once worked with a DBA who insisted that tables shouldn’t have more than 15 columns. So any table with more than 15 columns would have to be split into multiple tables, even if those tables would always have to be fetched together.

Re: Ask HN: What are some examples of good database schema designs?

#68

Take a look at http://www.softwaregems.com/Documents/Student%20Resolutions/ . I will refrain to comment on the quality of Drupal’s schema, but that diagram just shows a bunch of tables and how those tables are connected by foreign keys. What do those connections mean ? What other constraints are there in the data? Are they represented in the diagram? A good database design conveys a lot more semantics. There is curre…

I did a quick google search and ISO 31320-02 seems to be available only by paying ~170 CHF. Is there any text which explains how it is used? Even if I wanted to pay the aforementioned price I am afraid that I would get just a standard reference text with little or nothing in terms of actual teaching how is should be used and what the benefits are.

Re: Ask HN: What are some examples of good database schema designs?

#69

it really all depends on the requirements. i use to think wordpress had the worst schema in the world. after actually using it and writing plugins for it, i've come to the conclusion that it is genius. their schema design really makes it very easy for others to "extend" the structure without having to actually alter the schema. to elaborate on what i mean by extend, wordpress's schema is basically a post table that h…

After searching for years for what that design was called, I finally read somewhere that it’s the “property bag pattern”. Seemed fitting.

I've referred to it, and been understand as entity-attribute-value, or EAV.

Re: Ask HN: What are some examples of good database schema designs?

#70
A schema is a way of designing data structures such that they are efficiently organized and easy to use.

But that leaves the obvious question: use for what?

Structures, whether it's databases or object graphs, exist for only two reasons: to do stuff and to fit into a pattern of rules you've decided to use beforehand. Without either of those, there is no way to judge a schema. We could talk about generally organizing data. That's set theory and normal forms. But that wasn't your question.

I would design the schema for a three-microservice widely-distributed high-performance application far differently than I would a local checkbook app for my brother. You gotta have more information.

Apologies. I am unable to help.

Post reply on HN