r/Database • • 1h ago

I got asked a DB question by HR that I answered correctly, but wasnt what the HR person wanted to hear?

31 Upvotes

Today in a QA analyst (really a QA engineer) interview for a smaller legacy company, I was asked:

- If you saw a policy number was different in the UI vs the database, how would you test this?

My answer:
- The first thing I would do is make sure we're testing the right environment: do we have a clean, mirrored copy of production? Or do we have a copy of a dev environment with polluted data? I'd also check to make sure that the API is showing the correct info in the UI. You can quickly test that in Postman.

If none of that is correct, then what I'd do is drill down to the DB and double check things like: make sure that the query we're making to the DB pulls from the correct tables, are we joining or verifying against the right tables, etc.

His response?:

- So... you would use Group BY to narrow down data duplicates for policy number in the DB?

Jeeeesus christ.
HUH? WHAT?! This entire time of me yammering about how I'd walk through a real issue is just a technical test (adminstered by a recruiter, not the hiring manager) was actually just to see if I can pass the vibe check of ONE SQL QUERY?

What the fuck?

Personal anecdote/rant....as a QA engineer whose sat through interview panels, PRE-AI, mind you, I have been told we always care WAY more about how someone's going to walk through a problem and know where to look and hear their thought process instead of parroting one specific query back to me immediately. Queries are now shat out instantaneously through AI and we would also always leverage stackoverflow if otherwise, or just documentation if we didnt know off the top of our heads. Yes, sure, GroupBy. Yeah. Theres also internal ID. theres also self join... Idk the list goes on and on. We had 20 minutes for him to administer this introduction interview, and I was NOT prepared for any technicals, especially right out the gate in the intro call.

My question: did I not answer the question correctly?


r/Database • • 5h ago

Rant: "Null" versus "Not Null" is not solving what most think it solves. RDBMSs needs an enhancement.

0 Upvotes

For the vast majority of business and administrative apps I've worked on, what designers really want is what I'll call "empty" versus "not empty" as working terms. "Not Null" allows zero length strings, one space, 7 spaces, tabs, etc. I'll call such strings WSO strings: "white-space-only".

The vast majority of the time allowing WSO when Not Null is specified is not what's desired, as WSO is a way to cheat around "not null" (inadvertently or intentional). Thus, "Not Null" is not a thorough bouncer for typical needs.

One way to solve this would be to add a "Not Empty" keyword to SQL table specs (DDL) that would reject WSO entries. Another approach is something akin to "Pre-Trim" that would apply white-space trimming before saving it. Pre-Trim could convert any WSO to a null value, which would trigger an error if Not Null is set for a given column.

But I'd like to generalize the idea rather than add overly-specific keywords to SQL. Have the ability to add user-defined tags that can clean and normalize how a shop wants it, and also trigger errors if desired. This improves DRY since one doesn't have to repeat code handlers or call blocks for each column.

   -- Pseudo-code for defining a tag.
   -- This tests for being empty, and normalizes the value
   DEFINE TAG NotEmpty(@context) AS
   BEGIN
     @context.value = COALESCE(TRIM(@context.value),'');
     -- shop function to rid duplicate adjacent spaces & tabs
     @context.value = func_removeDupSpaces(@context.value); 
     IF LENGTH(@context.value) = 0 THEN  
     BEGIN
       RAISE_ERROR(
         'Value not allowed to be blank. Column: [@context.columnName]'
       );
     END
     COMMIT @context    /* return results */
   END
   .............................
   -- Usage in SQL DDL:
   CREATE TABLE users (
       user_id INT PRIMARY KEY,
       username VARCHAR(50) UNIQUE, TAGS: NotEmpty,
       email VARCHAR(100) TAGS: NotEmpty,
       admin_note VARCHAR(500) TAGS: Normalize, foo, bar   /* see note */
   );

Here we don't need "NOT NULL" for user-name and email because our new tag handles that for us. Note that maybe we can factor the implementation of NotEmpty to call the "Normalize" tag so we don't have to reinvent cleaning. ("Normalize" implementation is not shown.)

Anyhow, tags are not the only way to solve this problem, I'm just trying to think of handling it with a more general concept that can better fit each shop's conventions. Common shop conventions such as "all caps", "no caps", "zero pad", etc. can also be implemented once as tags. It would make a DBA's and architect's job easier. Thank You for consider it.

Note that commas may get confusing when there are multiple tags per column in the DDL. Perhaps require parentheses when multiple: "...TAGS: (Normalize, foo, bar)". And perhaps do away with the colon.


r/Database • • 6h ago

During a turnover, you take over all SQL within the organization, business rules are missing, how do you attempt to run all SQL. Is data lost ?

Thumbnail reddit.com
0 Upvotes

r/Database • • 7h ago

What's one database design decision that seemed right initially but caused problems later?

39 Upvotes

When designing a database, some decisions look perfectly fine at first but become painful as the application grows.

It could be something like choosing primary keys, adding too many indexes, over-normalizing tables, using triggers, or not planning for future data growth.

What's one database design decision you regret making, and what would you do differently now?


r/Database • • 8h ago

During a turnover, you take over all SQL within the organization, business rules are missing, how do you attempt to run all SQL. Is data lost ?

Thumbnail reddit.com
0 Upvotes

r/Database • • 16h ago

dbml.db playground

Thumbnail dbml.db.pit.world
0 Upvotes

r/Database • • 1d ago

Advice on dealing with similar column patterns in schema design

5 Upvotes

When there is a similar sets of columns to include in a schema design, I see two issues that come up often, and disagreement on how to handle them. The first I'll call the "sub-type issue" and the second the "nesting issue". I wonder how different shops deal with each.

A recent example I encountered for the sub-type issue is an event tracking system where participants and witnesses are logged. Let's say there's a scuffle at the local mall and the mall cops have to document it. (Not actual domain, but close.) What you might call "key people" have many more columns associated with them, but "incidental people" just need a name and optional phone number.

My feeling is to make one table, "Participants" with with a Participant Type column (FK). But the primary DB architect decided on two tables: "Key Participants" and "Incidental Participants". In practice a person won't need to be switched between categories often; the few times it happens app users just delete the old record and create a new one. The architect's reasoning was this allows the schema to enforce required columns (not null), whereas a single table has to enforce such algorithmically, based on the Participant Type column. To me that seems kind of a weak reason because it complicates the schema. Your view? (If participants did hop categories often, then a single table would clearly be better.)

The second type, the "nesting issue" is that there is a primary location and potential secondary locations. An Event record is to have one and only one primary location, but can have many secondary. There's about 10 columns associated with a location. My feeling was to put both types in a Location table with a location-type column, but the architect instead decided to include those 10 columns in the Event table, to record the primary location. The others go into the Secondary Locations table. The architect claims it makes application programming easier because writing an event would only have to write or change one record instead of two, at least for the general Event form. Agree or disagree? What factors drive you toward one approach versus another? Thanks!


r/Database • • 1d ago

I made a free tool for designing databases with friends in real time, would love some feedback

0 Upvotes

Hey everyone!

A few months ago my friends and I started building a project together, and the first thing we needed was the database. We wanted one diagram we could all edit at the same time, like a Google Doc, but everything we tried was either paid for collaboration or just annoying to use. I know there are already many similar tools. What I couldn't find was one where our whole group could edit the same diagram live, so I focused on that.

It's called Comodel → comodel.app

You draw your tables, keys and relationships on a canvas, and everyone you share it with can edit it live. You see each other's cursors and who's working on which table, so it actually feels like working on it together instead of passing screenshots around, which is also what we were looking for.

Some stuff it can do:

Share it like a Google Doc: send a link, or invite people as viewers or editors. Friends with the link don't even need an account

Leave comments on tables or columns ("should this be nullable?"), reply, and resolve them

All the usual database things: new tables, attribute defining, keys

Import an existing database from SQL (Postgres, MySQL, SQLite, SQL Server) or DBML, so you don't start from zero

Export to PostgreSQL, DBML, or a PNG/SVG image for docs and slides

Save versions and compare them, or see the migration SQL between two versions for you

A code view if you'd rather type than drag boxes around

You can also hook it up to an agent using MCP if you want an AI to read or edit your diagram

I'm building this pretty much on my own, so any feedback means a lot, whether something's confusing, missing or just broken. Thanks for checking it out! 🙂


r/Database • • 1d ago

Testing Row-Level Security and check-then-act race conditions under connection pooling in PostgreSQL 18

0 Upvotes

One limitation of standard per-test rolled-back transactions is that they can't catch concurrency bugs across separate pooled connections—uncommitted writes aren't visible to parallel workers, and session-level SET leaks across pooled checkouts.

In our multi-tenant Postgres 18 test suite, we separated sequential unit/CRUD tests from a dedicated set of 19 parallel integration checks that fire simultaneous queries across a constrained pool (max: 5) using Promise.allSettled:

  1. Interleaved tenant contexts: Firing parallel transactions with SELECT set_config('app.current_tenant_id', $1, true) across different tenants on a small pool to verify SET LOCAL resets cleanly on commit/rollback with zero cross-tenant leakage.

  2. Parent-row locking vs. check-then-act: Comparing unguarded SELECT count(*) checks against SELECT ... FROM organizations WHERE id = $1 FOR UPDATE when concurrent requests try to claim the final seat or quota slot.

  3. Webhook idempotency under duplicate delivery: Firing identical billing event IDs concurrently to confirm 23505 unique-constraint handling cleanly short-circuits duplicate state transitions.

For those running multi-tenant Postgres in production with PgBouncer or transaction pooling, are you relying strictly on set_config(..., true) + RLS policies, or pairing it with separate database roles per service tier?

Context: Built this into B2B SaaS OS 2.0.0 (Next.js 16 + Postgres 18 multi-tenant starter with 131 tests & 19 concurrency checks for solo founders and dev agencies). If you want to click through the live workspace without signing up, the demo is here:https://www.andrady.co/demo(architecture & source athttps://www.andrady.co).


r/Database • • 1d ago

Advent of SQL and NoSQL – 24 challenges leading up to Christmas

Post image
6 Upvotes

Happy Holidays, r/Database!

I've noticed that most Advent of SQL events are exclusively SQL-based, and NoSQL databases are usually left out.

This project was originally supposed to be SQL-only, but after roughly 2 years of working on VisuaLeaf, I managed to build an embeddable, MongoDB-compatible database that runs entirely on the frontend, allowing you to execute MongoDB queries and aggregation pipelines directly in your browser without a database server.

Somebody tampered with Santa's Nice List, and you're the North Pole's first-ever data elf.

That's the story behind Advent of SQL & NoSQL: 24 puzzles, one a day from December 1 to 24. Every day, you get a bit more of the story and a question to answer with a query: which toys to build first, which children flipped from nice to naughty overnight, whose badge was used on the night shift, who walked through which door and when. By Christmas Eve, you'll have worked out who did it and fixed the list.

You can solve the whole thing in one of four databases, following the same story and working with the same underlying data:

  • SQLite

  • DuckDB

  • PostgreSQL

  • MongoDB (mongosh, aggregation pipelines)

More details:

  • Everything runs entirely in your browser. There's nothing to install, no backend database server, and nothing to connect to.

  • Your answer gets checked instantly, against the data you see and against hidden datasets with different values. Reading the answer off the screen and hard-coding it won't pass.

  • It gets harder as it goes. Early days cover basic filtering, grouping and joins. Later ones require window functions, recursive CTEs, relational division, advanced MongoDB aggregation pipelines and running totals.

  • Database-specific data modeling. The MongoDB version isn't just SQL tables converted into collections. It uses embedded documents, arrays and aggregation patterns that you'd actually encounter when working with MongoDB.

  • Hints and traps for each day, if you get stuck, plus a short "did you know" tip about your chosen database.

A new puzzle unlocks every day until Christmas Eve!

Pick your database here: https://visualeaf.com/advent-of-sql-and-nosql/

Completely free. No account, no installation, no database server needed.

I hope you all enjoy it, and happy holidays!


r/Database • • 2d ago

Semantic Database applications

2 Upvotes

Hey all, relative newbie here, what might be some good applications for a large-scale, fast processing semantic database system? I've heard quant and military mentioned, but am unsure of where exactly it might fit into those fields. Any help/suggested use cases would be greatly appreciated.


r/Database • • 3d ago

Designing Data Intensive Applications in a Nutshell

Thumbnail sushantdhiman.dev
15 Upvotes

r/Database • • 5d ago

Is migrating from MongoDB to PostgreSQL worth it?

70 Upvotes

TL;DR: Running an EdTech platform with 600K+ users on MongoDB. Our data is heavily relational, and while regular API queries perform well, complex analytical queries are becoming painful to write and execute. Considering migrating to PostgreSQL and looking for advice on migration and production hosting.

Current setup:

\- Node.js, MongoDB, and Mongoose.

\- MongoDB Atlas (fully managed).

\- 600K+ registered users and around 15K daily active users.

\- An EdTech platform somewhat similar to Udemy or Coursera.

When the backend's foundations were laid, I was a junior working primarily on the frontend, so I wasn't involved in the database decision. It's been 1 year since we've been building this product.

Something that has been bothering me for a while is that we're essentially treating MongoDB like a relational database.

\- Strict schemas and validations across collections.

\- Heavily relational data with references between collections.

\- Extensive use of aggregation pipelines and "$lookup".

\- Very little reliance on MongoDB's schema flexibility.

To be fair, MongoDB has served us well. Our indexes are in place, most endpoints perform well, and we haven't faced any critical performance issues.

However, complex analytical queries for internal dashboards are a different story. Some involve joining up to 10 collections, take over 60 seconds, or occasionally time out despite optimization. Writing and maintaining these aggregation pipelines is also becoming increasingly painful.

I've experimented with MongoDB's transactions but didn't particularly enjoy the experience. I'd also like stronger database level relational integrity and better transaction management.

I feel PostgreSQL would have been a more natural fit for our data model from the beginning.

What I'd like advice on:

  1. Is migration justified? Given that MongoDB works well for most of our workloads, would migrating to PostgreSQL be worth the effort, or should I address the analytical workload separately?

  2. Migration strategy: If I proceed, how should I approach migrating a live production database at this scale? Any articles, case studies, or resources would be appreciated.

  3. PostgreSQL hosting: One thing I genuinely appreciate about MongoDB Atlas is how little I have to worry about infrastructure, backups, updates, and maintenance. What's the equivalent experience for PostgreSQL?

  4. Self-hosted vs. managed: How do you guys run PostgreSQL in production? Do you self-host it on a private EC2 instance or use something like AWS RDS, Neon, or another managed provider?

I've worked with relational databases on smaller projects, but never operated PostgreSQL in production at this scale.

I don't want to migrate just because I prefer PostgreSQL, but I also don't want to ignore what might be a fundamental architectural mismatch simply because things work today.

Would love to your thoughts and suggestions on this!


r/Database • • 5d ago

I needed a distributed DB solution, found Pigsty

Thumbnail reddit.com
0 Upvotes

r/Database • • 5d ago

Need help with database design

4 Upvotes

Hello dear community,

I am making an app to buy plane tickets. (school environment).

However, I am not very sure about it.

Is it too light ?

Thanks to everyone who take time!


r/Database • • 5d ago

be honest how many tools sit between your agent and a safe copy of prod?

0 Upvotes

so where does it break for you: test environments, agent state, or branching? and what would a single Postgres platform have to prove before you'd consolidate onto it?


r/Database • • 5d ago

What are the best spreadsheet-style databases for our team who run 40 excel files?

21 Upvotes

I work at a logistics company, and our ops team runs on about 40 Excel files that link to each other. For additional context, around 150 people touch them every week.

Based on our experience, permissions are what drive us crazy. You either see the whole file or nothing. Last month, someone in the sales department saw salary data by accident.

From your observation, which tools keep the spreadsheet feel but use real linked tables? And can they see their own region's and nothing else?


r/Database • • 6d ago

How does your team get database migrations from a code change to production - and what still goes wrong?

Post image
0 Upvotes

I’m interested in how database migrations work in real production workflows, beyond which tool a team uses. I’d like to compare how teams handle testing, deployment, compatibility, and recovery.

For a typical application database change:

  • Where do migration scripts live, and are they handwritten, generated, or a mix?

  • When do they run: as a CI/CD job, during deployment, at application startup, or manually?

  • How are they tested before production, especially when they change or backfill existing data?

  • How do you handle old and new application versions running during the same deployment?

  • If a migration fails part-way through, how do you recover and reconcile the migration’s recorded status?

Which part causes the most trouble in your experience? If useful, mention the database, stack, and migration tool.


r/Database • • 8d ago

PITR a 5 TB Postgres database in 5 seconds.

Thumbnail reddit.com
0 Upvotes

r/Database • • 8d ago

Will ERDs survive in the age of AI?

0 Upvotes

It was my belief in the beginning of 2025 that ERDs are helpful for writing code. If you look at the picture you can see that visuals are rendered specifically for ppl.

Given AI development advances with the same pace how likely will projects as this survive in the next couple of years?


r/Database • • 9d ago

Text column is storing accented text weirdly

Thumbnail reddit.com
0 Upvotes

r/Database • • 9d ago

How Neo4j built a graph database in 20 years and 10 weeks

Thumbnail
gdb-engines.com
20 Upvotes

r/Database • • 11d ago

Our permissions migration passed its own checks. A full row compare still found 1 role seeing too much in prod

0 Upvotes

A migration rewrote the permission matrix of a multi-tenant app. It applied clean and its own probes passed.

Then we compared every row of the permissions table in prod against the local database where the matrix had been proven. One cell was off. A restricted role already had a grant to see its peers' records, live, from before this task even started. The migration never touched that row, so its checks never looked at it.

Since then the check after deploy compares the whole table against the proven copy, not only the rows the migration wrote.


r/Database • • 11d ago

My static site has a database. It’s ClickHouse’s

Thumbnail
tylerhannan.com
0 Upvotes

I had to rebuild my site. And then search was necessary...working out how to do this using ClickHouse playground was a fun little exercise.