Ben Brumm (@databasestar) header
Ben Brumm (@databasestar) profile picture

Practical database advice for developers. Oracle, SQL Server, MySQL, PostgreSQL, & database design

Melbourne, Australia
Joined May 2011
Photo by Ben Brumm (@databasestar)Photo by Ben Brumm (@databasestar)Photo by Ben Brumm (@databasestar)Photo by Ben Brumm (@databasestar)Photo by Ben Brumm (@databasestar)Photo by Ben Brumm (@databasestar)Photo by Ben Brumm (@databasestar)Photo by Ben Brumm (@databasestar)Photo by Ben Brumm (@databasestar)Photo by Ben Brumm (@databasestar)
A tutorial on using TimescaleDB to load time-series data and create a visualisation: youtube.com/watch?v=ERtcMDuP…
1
235
This seems pretty exciting! I've just started playing around with TimescaleDB and this seems pretty interesting.
Agents are the New Developer Agents, like Claude Code, feel uncanny. My first time using it, I built a mobile web app that tracked pushups using computer vision. Just for fun, to see what it could do. One hour later (mostly its time, not mine), I had an app that just worked. That gave me goosebumps. For the first time, it felt like software wasn't something I built, it was something building with me. It felt like something brand new. I realized: agents had become the new developer. But software agents don't behave like human developers. Software development tools need to evolve. Agents need a new kind of database made for how they work. So we built it. And we're launching it today. Announcing Agentic Postgres: The First Database Built For Agents. There's a lot of engineering behind this: a new copy-on-write block storage layer, fast zero-copy forks, new Postgres extensions for full text search (BM25) and semantic search, what (we think is) the best MCP server for Postgres ever built, and a new CLI and free tier. I'm very proud of what this team has built, especially in such a short period of time. More here: tigerdata.com/blog/postgres-… Please give it a try. We're just getting started. We’d love your feedback. 🐯🚀 @TimescaleDB @TigerDatabase
1
3
354
Are you adding a phone number to your database design? I recommend storing it as a text or varchar field, NOT as a number. The phone number does not need to be added or subtracted. Storing it as a number can remove leading zeroes. So, store it as a text value.
1
8
631
Do you want to store images in your database? You could store them in a BLOB field… But I would store them on the server and add the image URL to a varchar field in the table. They are easier to work with and backup. There’s no benefit to storing an image in a BLOB.
1
260
Don’t use SELECT * in production code. It’s great for quick investigations and scripts. But using it in production code has issues. The order isn't guaranteed, you can't use aliases, and you retrieve more data than is necessary. It’s better to specify the individual columns.
1
231
I work with several different databases. Here are the editors I use for each vendor: - Oracle: VS Code with the SQL Developer extension - SQL Server: SSMS - MySQL: MySQL Workbench - Postgres: DBeaver
1
1
3
1,208
EAV stands for Entity Attribute Value, and it’s a database design that allows data to be captured in a flexible way. In almost all cases, it’s not a good idea. It doesn’t enforce data types or referential integrity. It's solving the wrong problem. Normalise the design instead.
1
1
278
Should you use UUID or Integers for your primary key? Both have their pros and cons. What do you think?
5
881
An audit table for your database can be used to store a history of changes made to records. Create a table with the same structure as your main table, add columns to capture the created and updated datetime, and populate it with triggers or stored procedures.
2
160
If you need to calculate a running total, use SUM as a window function. You can use the OVER clause and the PARTITION BY clause to calculate a running total for your results, combining the concept of an aggregate function with showing the details of each record.
157
What is a subquery in SQL, and why would you use it? A subquery is a Select query that is contained within another query.
1
152
The main reason you would want to use a subquery is when the results of one query need to be used in another query to get the results you need.
1
105
A common example is finding records greater than the average: first we need to find the average (using a subquery), then find records with a value greater than this average.
2
100
How do you know which way a one-to-many relationship goes? Ask yourself: “Does Table A have many Table B’s, or does Table B have many Table A’s?” From your answer, the table with the “many” has the foreign key to the primary key in the other table.
116
Before you run a DELETE or UPDATE statement, replace the DELETE or UPDATE with the word SELECT. Run the SELECT query to see which rows will be impacted by the DELETE or UPDATE. It's an easy way to check your action before you do it: and avoid changing the wrong data!
1
158
Installing #Oracle #SQL #Developer is now as easy as searching for 'sql-developer' in VS Code. social.ora.cl/6018rRdoj
7
58
8
163
29,077
The @OracleSQLDev extension for VS Code was just released. I've just published a YouTube tutorial on how to install it, connect, and some of the features: youtube.com/watch?v=0D8hf2Fj…
1
1
212
Ben Brumm retweeted
It's a weak move to reply to someone by quote-tweeting your reply to an audience of your own followers.
283
77
220
1,756
569,728
Need to capture addresses in your database? I recommend a separate address table, which is linked to your other tables with a joining table (e.g. customer_address linked to customer and address). This allows you to capture the address type as well as address changes over time.
1
2
344
What tool do I use and recommend for creating Entity Relationship Diagrams? Personally, I use LucidChart. It's web-based and easy to use and edit. I also suggest using the built-in tool in your SQL Editor. MySQL Workbench, SSMS, pgAdmin, and SQL Developer all have one.
1
1
430