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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:22:21+00:00 2026-06-09T16:22:21+00:00

I had to implement the following into my database: The activities that users engage

  • 0

I had to implement the following into my database:

  • The activities that users engage in. Each activity can have a name with up to 80 characters, and only distinct activities should be stored. That is, if two different users like “Swimming”, then the activity “Swimming” should only be stored once as a string.

  • Which activities each individual user engages in. Note that a user can have more than one hobby!

So I have to implement tables for this purpose and I must also make any modifications to existing tables if and as required and implement any keys and foreign key relationships needed.

All this must be stored with minimal amount of storage, i.e., you must choose the appropriate data types from the MySQL manual. You may assume that new activities will be added frequently, that activities will almost never be removed, and that the total number of distinct activities may reach 100,000.

So I already have a ‘User’ table with ‘user_id’ as my primary key.

MY SOLUTION TO THIS:
Create a table called ‘Activities’ and have ‘activity_id’ as PK (mediumint(5) ) and ‘activity’ as storing hobbies (varchar(80)) then I can create another table called ‘Link’ and use the ‘user_id’ FK from user table and the ‘activity_id’ FK from the ‘Activities’ table to show user with the activities that they like to do.

Is my approach to this question right? Is there another way I can do this to make it more efficient?

How would I show if one user pursues more than one activity in the foreign key table ‘Link’?

  • 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-09T16:22:22+00:00Added an answer on June 9, 2026 at 4:22 pm

    Your idea is the correct, and only(?) way.. it’s called a many to many relationship.

    Just to reiterate what you’re proposing is that you’ll have a user table, and this will have a userid, then an activity table with an activityid.

    To form the relationship you’ll have a 3rd table, which for performance sake doesn’t require a primary key however you should index both columns (userid and activityid)

    In your logic when someone enters an activity name, pull all records from the activity table, check whether entered value exists, if not add to table and get back the new activityid and then add an entry to the user_activity table linking the activityid to the userid.

    If it already exists just add an entry linking that activity id to the userid.

    So your approach is right, the final question just indicates you should google for ‘many to many’ relationships for some more info if needed.

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

Sidebar

Related Questions

I have following challenge: Implement a function that searches for a null point of
I had try to implement the send me log feature into my apps but
Following code create that Annotation. As described here, http://engineering.webengage.com/2012/03/12/a-peek-into-webengages-security-layer-super-cool-use-of-java-annotations /** * Defining the Asynch
I am trying to use Ninject to implement cascading injection into a class that
I'm attempting to implement a phpBB library into Kohana. I have created a vendor
As part of my homework project I had to implement a library that implements
I had implement this push notification . I tried with push first message, it
I had asked a question on how to implement real time updates in ASP.NET
I'm trying to implement this algorithm description from a previous question I had here
I am trying to implement a image recognition program in C++ . I had

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.