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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:31:43+00:00 2026-06-10T00:31:43+00:00

I currently have a model Feature that is used by various other models; in

  • 0

I currently have a model Feature that is used by various other models; in this example, it will be used by customer.

To keep things flexible, Feature is used to store things such as First Name, Last Name, Name, Date of Birth, Company Registration Number, etc.

You will have noticed a problem with this – while most of these are strings, features such as Date of Birth would ideally be stored in a column of type Date (and would be a datepicker rather than a text input in the view).

How would this best be handled? At the present time I simply have a string column “value”; I have considered using multiple value columns (e.g. string_value, date_value) but this doesn’t seem particularly efficient as there will always be a null column in every record.

Would appreciate any advice on how to handle this – thanks!

  • 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-10T00:31:44+00:00Added an answer on June 10, 2026 at 12:31 am

    There are a couple of ways I could see you going with this, depending on your needs. I’m not completely satisfied with any of these, but perhaps they can point you in the right direction:

    1. Serialize Everything

    Rails can store any object as a byte stream, and in Ruby everything is an object. So in theory you could store string representations of any object, including Strings, DateTimes, or even your own models in a database column. The Marshal module handles this for you most of the time, and allows you to write your own serialization methods if your objects have special needs.

    Pros: Really store anything in a single database column.

    Cons: Ability to work with data in the database is minimal – It’s basically impossible to use this column as anything other than storage – you (probably) wouldn’t be able to sort or filter your data based on it, since the format won’t be anything the database will recognize.

    1. Columns for every datatype

    This is basically the solution you suggested in the question – figure out exactly which datatypes you might need to store – you mention strings and datestamps. If there aren’t too many of those, it’s feasible to simply have a column of each type and only store data in one of them. You can override the attribute accessor functions to use the proper column, and from the outside, Feature will act as though .value is whatever you need it to be.

    Pros: Only need one table.

    Cons: At least one null value in every record.

    1. Multiple Models/Tables

    You could make a model for each of the sorts of Feature you might need – TextFeature, DateFeature, etc. This guide on Multiple Table Inheritance conveys the idea and methodology.

    Pros: No null values – every record contains only the columns it needs.

    Cons: Complexity. In addition to needing multiple models, you may find yourself doing complex joins and unions if you need to work directly with features of different kinds in the database.

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

Sidebar

Related Questions

I want to turn Model.attribute into Attribute.models. e.g. I currently have Model.first.attribute => string
I currently have a client that wants me to 'abstract' out a domain model
I currently have two different models: User and Project . The User model has
Currently I have a database of Courses, and it has 6 columns: class Course(models.Model):
I currently have a DetailView for Django's built-in User . url( r'^users/(?P<pk>\d+)/$', DetailView.as_view( model
Currently I have a DateTime property for a model. I am using the telerik
I have a model User . The model currently works with a Register view
I currently have two Backbone models: user and project. I would like to have
I currently have the following models/toy.rb file in my RoR project: class ToysPurchased include
In the Rails application I’m currently developing I have many request models. We are

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.