Re:Do you really need foreign keys?
by mavelikara on Thursday December 21, 2023 @01:29PM
(#38724545)
+1. When I started in the industry, it was common for more experienced developers to drill the “data outlives the application that generated it” principle into you. Somewhere in the transition to NoSQL and back we lost this.
[ Parent
| on HN ]
The _data_ yes, the _database_ no. The data will get migrated to different solutions at different times. I've lost track of how often I've been porting MySQL to SQL Server, SQL Server to Postgres, Postgres to Mongo, Mongo to cloud etc.
EDIT: fixed capitalization of "PostGres"
This really depends on the size of your data set. If you have a large database (TBs+) it's likely to be very long-lived due the effort/hardware resources a migration requires - especially if you want to improve the schema when migrating.
I’ve seen a database migration project outlive application rewrites, multiple changes in CTO, and the company being acquired.
Friendly suggestion: the conventional capitalization is either Postgres or PostgreSQL.
Re:Do you really need foreign keys?
by da_chicken on Thursday December 21, 2023 @04:29PM
(#38727237)
It wasn't the transition to NoSQL. It was the transition to web APIs. Now the application that can access the database has a universal shim in place that deals with the messy business of taking requests and applying them to the data store.
Now there's typically three applications that need DB access:
1. The application it was built for.
2. The read-only reporting and visualization tools.
3. The web API.
Re:Do you really need foreign keys?
by SkyPuncher on Thursday December 21, 2023 @03:03PM
(#38726048)
Context is key.
If you have an established business or startup, data will outlive the application. However, you need a product that lives long enough for either data or application to matter.
In the startup world, that means making decisions that help you ship now, at the expense of debt/costs down the road.
Re:Do you really need foreign keys?
by mavelikara on Thursday December 21, 2023 @06:28PM
(#38728617)
IME, Foreign Keys do not slow down development velocity, after you factor out the upfront time investment it takes to understand them, normal forms, and other RDBMS concepts. Other posters in this thread have argued that they take CPU cycles during program execution - which is factual correct.