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 7075333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:09:53+00:00 2026-05-28T06:09:53+00:00

We are currently building a PostgreSQL database that allows us to create profiles for

  • 0

We are currently building a PostgreSQL database that allows us to create profiles for hardware. Each profile exists of a few different properties which are all dynamically added to the profile through the UI. Each property can be of a different type (string, integer, text, …)

How would I most efficiently store these properties in a relational database?

I’ve read Storing diverse value types in a database and I’m charmed by the single answer there but I’m not at all confident that this is the ideal solution. Are there any pros/cons using the separate-table-per-type approach over the other solutions? Anyone has real world experience with this and minds shedding some light on the best approach?

  • 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-28T06:09:54+00:00Added an answer on May 28, 2026 at 6:09 am

    My preferred way is single table with both key and value being varchar and/or text.

    The only big disadvantage of table-per-type in that comment I can think of is that it’s hard to constraint the uniqueness of the key in pair with the entity this key-value entry belongs to.

    Table inheritance (but still with table-per-type) would be another way to go and IMHO it’s brutally type-safe and compliant with postgres and ORM concepts:

    CREATE TABLE key_values(user_id integer references users(id), key varchar(255), type varchar(255), CONSTRAINT UNIQUE(user_id, key));
    CREATE TABLE key_values_int(value integer) INHERITS (key_values);
    CREATE TABLE key_values_string(value varchar(255)) INHERITS (key_values);
    and so on...
    

    This perfectly maps to JPA.

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

Sidebar

Related Questions

I am currently building an application that consists of several components, each of which
Im currently building an web-app that allows users to upload content via blobstore and
I'm currently building a framework that uses a MySQL database. I can't use the
I'm currently building a Java app that could end up being run on many
We're currently building an application that executes a number of external tools. We often
I'm currently building a small web application that includes a fair amount of JavaScript.
I'm currently building an app that contains around 60 or so tables, some with
Context I'm building a persistence layer to abstract different types of databases that I'll
I am currently building a Rails 3.2 application that uses the gem sunspot to
I am currently building a Website that uses a blackletter font. I try to

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.