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

  • SEARCH
  • Home
  • 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 6116749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:14:31+00:00 2026-05-23T15:14:31+00:00

How should I store a user’s height and weight in a MySQL database such

  • 0

How should I store a user’s height and weight in a MySQL database such that I can use the information to find users within a certain height or weight? Also, I will need to be able to display this information in either English or metric system.

My idea is to store the information for height in centimeters and weight in kilograms (I prefer metric over English). I can even let the user enter their information and English system, but do the conversion to metric before saving. I think converting kilograms to pounds might be easy to do in SQL, but I’m not sure how easy it would be to convert 178 centimeters to 5'10" (rounded slightly down).

Should I be saving English and metric values in the database so that I don’t need to do conversions when I do my queries? Sounds like a bad idea to store derived/computed values.

  • 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-05-23T15:14:32+00:00Added an answer on May 23, 2026 at 3:14 pm

    There are several ways… one is to just have two numeric columns, one for height, one for weight, then do the conversions (if necessary) at display time. Another is to create a “height” table and a “weight” table, each with a primary key that is linked from another table. Then you can store both English and metric values in these tables (along with any other meta info you want):

    CREATE TABLE height (
        id          SERIAL PRIMARY KEY,
        english     VARCHAR,
        inches      INT,
        cm          INT,
        hands       INT  // As in, the height of a horse
    );
    
    INSERT INTO height VALUES
        (1,'4 feet',           48, 122, 12),
        (2,'4 feet, 1 inch',   49, 124, 12),
        (3,'4 feet, 2 inches', 50, 127, 12),
        (3,'4 feet, 3 inches', 51, 130, 12),
        ....
    

    You get the idea…

    Then your users table will reference the height and weight tables–and possibly many other dimension tables–astrological sign, marital status, etc.

    CREATE TABLE users (
        uid         SERIAL PRIMARY KEY,
        height      INT REFERENCES height(id),
        weight      INT references weight(id),
        sign        INT references sign(id),
        ...
    );
    

    Then to do a search for users between 4 and 5 feet:

    SELECT *
    FROM users
    JOIN height ON users.height = height.id
    WHERE height.inches >= 48 AND height.inches <= 60;
    

    Several advantages to this method:

    • You don’t have to duplicate the “effort” (as if it were any real work) to do the conversion on display–just select the format you wish to display!
    • It makes populating drop-down boxes in an HTML select super easy–just SELECT english FROM height ORDER BY inches, for instance.
    • It makes your logic for various dimensions–including non-numerical ones (like astrological signs) obviously similar–you don’t have special case code all over the place for each data type.
    • It scales really well
    • It makes it easy to add new representations of your data (for instance, to add the ‘hands’ column to the height table)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Should I use decimal or float to store a ratio in a database? Particularly
In Android, you can store user's config in preferences file. So where should the
I learnt that I should Store UTC and Show in local time. How can
I'm trying to design a MySQL database to store user zipcode preferences for providing
I'm a new Windows programmer and I'm not sure where I should store user
how should I store user data in asp.net mvc? Let's say a user want
In my application I use some icons. Where should I store the path of
I wonder how I should use the GTree (from GLib) to store data? Every
I've been told that it is insecure to store things such as passwords, usernames,
Should I store the user's ID, name & email address in a session variable

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.