When designing databases for your Spring Boot applications, one often overlooked detail can cause unexpected headaches: the character format of your table and column names. Let me share a recent experience that highlights why using ASCII characters is crucial.
Recently, I was working on a Spring Boot project where the database tables had names in full-width characters (like users
instead of users
). This caused issues as the data sent from the backend didn't seem to update the 'users' table. This is obvious as the DB will look at ASCII and full-width as completely different names even if they are the same word.
Full-width characters are characters occupy a space twice as wide as typical ASCII characters. For example:
users
users
While they might look similar, they're actually completely different under the hood!
Using standard ASCII characters for table names offers several benefits:
Here's how to maintain clean database naming:
-- Good (ASCII)
CREATE TABLE users (
user_id BIGINT PRIMARY KEY,
username VARCHAR(255)
);
-- Avoid (Full-width)
CREATE TABLE users (
user_id BIGINT PRIMARY KEY,
username VARCHAR(255)
);
If you find yourself with full-width table names, here's a simple process to convert them:
🚀