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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:33:18+00:00 2026-05-28T16:33:18+00:00

Looking for some suggestions on how to store my RoR data. Essentially, I have

  • 0

Looking for some suggestions on how to store my RoR data. Essentially, I have 20 or so items (will never go above 50) that I need to track. Each item has a different X,Y coordinate at each time of day (one of either Morning, Afternoon, Evening), and each of the seven weekdays it has a different schedule (essentially, 21 different x,y points for each time of day/day of week combination). It also has some static values, such as the name, category, and whatnot.

Right now I’m trying to decide how I want to store it, those 21 different x,y points. I suppose there are two opposite extremes on the spectrum – either (a) store each field like wednesday_afternoon_x, wednesday_afternoon_y, etc, or (b) serialize and store as a hash/struct, like x.wednesday.afternoon or something. A third option might even be to break them up into separate tables (ie have a :tuesday_item, :wednesday_item models, etc)

One thing that I do need to be able to do is search/filter by those fields – for example, if I want to get the items that are within a specific Category for a given TimeOfDay and DayOfWeek.

Are there any recommendations as to how I should proceed? 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-05-28T16:33:19+00:00Added an answer on May 28, 2026 at 4:33 pm

    I’d use two database tables, one for items, and one for coordinates. The schema then would be simple:

    create_table :items do |t|
      t.string :name
      t.string :category
      t.string :whatnot
    end
    
    create_table :item_coordinates do |t|
      t.references :item
      t.integer :x
      t.integer :y
      t.string :time_of_day
      t.string :weekday
    end
    

    [UPDATE: When you actually create these migrations, don’t forgot to add indexes! For item_coordinates, you probably want a joint index on [:item_id, :weekday, :time_of_day], but don’t take my word for that — figure out which fields you actually end up using as keys and index those.]

    Your Item model would has_many :item_coordinates and your ItemCoordinate model would belong_to :item.

    Then you can use all the regular ActiveRecord methods. For example, to get a specific coordinate easily under this system:

    item_coordinate = Item.find(item_id).item_coordinates.where(:time_of_day => 'afternoon', :weekday => 'wednesday')
    coords = [item_coordinate.x, item_coordinate.y]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am looking for some suggestions on the best way to store a very
I have never designed a database/data-model/schema from scratch, especially for a web-application. In some
I'm looking for some suggestions on how to go about this. Any input is
I'm looking for some suggestions as to how I could implement a World Map
Looking for some direction here as I'm running into some migration problems. We have
Looking for some help with a Labview data collection program. If I could collect
Looking at some code I'm maintaining in System Verilog I see some signals that
Looking for some guidance on a WCF service I’m prototyping. I have a WCF
I have a small database that I need help designing. I have a VB.NET
Im using a Core Data model for my iPhone app. I have been looking

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.