Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8778317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:30:22+00:00 2026-06-13T19:30:22+00:00

I need to design a database table where most attributes have units. For example:

  • 0

I need to design a database table where most attributes have units. For example:

Readings
--------

id   load (kW)   fuel_consumption (tonnes) - etc
1    1154        89.4
2    1199        54.2

What’s the recommended way to capture the units in the design? For example, I could:

  • store units within attribute names e.g. load_kW and fuel_consumption_tonnes
  • store units in a separate table e.g. each value becomes a foreign key to another table with columns for value and unit.
  • store outside the database: e.g. in business logic, or in documentation
  • are there others?

I happen to be using MySQL, but I assume this is a generic database normalisation problem.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T19:30:23+00:00Added an answer on June 13, 2026 at 7:30 pm

    Interesting question…

    There are two obvious routes:

    id   load_kW     fuel_consumption_tonnes
    --------------------------------------------------
    1    1154        89.4
    2    1199        54.2
    

    This is easy for humans to read, and fairly logical. However, if some readings are in “kilos”, others in “tonnes”, you have to convert those readings to fit into the “readings” table; this process MUST be “lossless”, and idempotent. For instance, a reading of “89403 kilos” is not “89.4 tonnes”, even though the business may choose to round from kilos to tonnes for convenience. There are usually some counter-intuitive rounding things that happen…

    If that’s the case, you could change the schema:

    id      load load_unit    fuel_consumption fuel_consumption_unit
    --------------------------------------------------
    1    1154  kW          89403              kg
    2    1199  kW          54.2               t
    

    With a “unit” table, if you need it:

    unit_id    unit_name
    --------------------
    kg         kilogramme
    t          Tonne
    

    However, this model is open to human failure – it would be easy to change the “load_unit” column without modifying the “load” column, thus breaking the data. There’s nothing you can really do to your data model to avoid this. It also makes common queries fairly tricky: imagine trying to retrieve the total of “load” in a consistent unit of measurement.

    I would recommend that in this case, you have two tables: “raw_readings”, with the original data in the format above, and “normalized_readings”, which you populate by converting all the readings to a consistent unit of measurement.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am testing my database design under load and I need to retrieve only
I have a legacy database with a pretty evil design that I need to
I have the following database design: Employees Table: EmployeeID, Name, OrgCode Departments Table: OrgCode,
I have the following database design: Employees Table: EmployeeID, Name, OrgCode Departments Table: OrgCode,
I need to create a database design where bar or event owners (admin-table because
I have the following database design: Users Table: NetworkID, Name, BadgeNo, DepartmentCode Events Table:
I need help on the best way to design a database/tables for the following
I need to design database for SQL Server, is there any MySQL workbench like
Please help an EF n00b design his database. I have several companies that produce
For most database-backed projects I've worked on, there is a need to get startup

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.