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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:07:50+00:00 2026-06-17T07:07:50+00:00

I need to create a database for managing teams. The 2 tables im wrestling

  • 0

I need to create a database for managing teams. The 2 tables im wrestling with are the meet table and the events table.

Here is the basic flow

Team A can create a new track meet which will add 1 row to the meet table with meta data for the meet such as dates, location it also has to include a list of events.

Events is a table of about 500 possible events that can be competed at during a meet. Things such as distance, type of event, male / female, age

I want during the generation of a meet for the user to be able to select which events that meet will have.

So create a new meet, complete meta data, and select (for Ex) 30 events from a list of all possible events.

Soooo my question is what table structure best supports that. I was thinking of a column in my meet table that holds and array of events.? But is there a better way to handle that.? Im using postgres and rails

  • 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-17T07:07:51+00:00Added an answer on June 17, 2026 at 7:07 am

    This sounds like a perfect use for the Rails has_many :through association. You should have a meet_events join table. The meet_events table would have a foreign key (belongs_to) meet_id column in it which points to the meet it is associated with and an event_id column in it which points to one of the available events. Your Meet model would use has_many :meet_events and has_many :events, :through => :meet_events. That will allow you to get the event objects associated with this meet.

    The MeetEvent model simply has two belongs_to. One for the meet and one for the event.

    Here’s a simple set of models:

    class Meet < ActiveRecord::Base
      has_many :meet_events
      has_many :events, :through => :meet_events
    end
    
    class Event < ActiveRecord::Base
      has_many :meet_events
      has_many :meets, :through => :meet_events
    end
    
    class MeetEvent < ActiveRecord::Base
      belongs_to :meet
      belongs_to :event
    end
    

    Here’s an example of some data and what it is modeling:

    meets

    id  |  name
    ------------------
    1   |  Meet 1
    2   |  Meet 2
    

    events

    id  |  name
    ------------------
    1   |  Event 1
    2   |  Event 2
    3   |  Event 3
    

    meet_events

    id  |  meet_id  |  event_id
    ----------------------------
    1   |  1        |  1
    2   |  1        |  3
    3   |  2        |  2
    4   |  2        |  3
    

    This is basically modeling that Meet 1 has Event 1 and Event 3 in it. Meet 2 has Event 2 and Event 3. This also gives you the benefit of asking a particular Event what meets it is in. So for example, calling event.meets when event is Event 3, it will tell you that both Meet 1 and Meet 2 have that event in them.

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

Sidebar

Related Questions

I need to create a table that will combine two database tables together. Both
i need run code that will create a database and populate tables. i am
I need to create database objects (table, index, keys, views, functions, etc.) through the
I need to create database tables to store memo. in the To clause user
I need to create a database design where bar or event owners (admin-table because
I need to create a database solution to provide product discounting. Current tables: Products
I am implementing a push notification service. I would need to create a database
I need to create a simple mySQL database with a field for an image.
I need to create a playlist in database, to know when each video will
I need to create a simple application that would generate reports based on database

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.