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

  • Home
  • SEARCH
  • 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 220509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:56:44+00:00 2026-05-11T18:56:44+00:00

I am creating a simple design for a social-networking site using the MVC paradigm(in

  • 0

I am creating a simple design for a social-networking site using the MVC paradigm(in CakePHP) for a project,
I have a table called Users which stores all the User Details, I have a Groups Table which stores all the Group details, the relation between these 2 models is has and belongs to many, then I have a group_portfolios table which stores all portfolios belonging to a group and a user_portfolio table which stores all portfolio information related to a user.
A user can have multiple portfolios
A group can have multiple portfolios
A user can have many media
A group can have many Media

I have separated the functionality for media associated with users and groups, My question would be,

1) am I thinking in the correct way in terms of modelling an MVC application?
2) Since I am separating the the functionality for users and groups I am ending up with 2 tables for all information related to them e.g media and portfolio. Does this cause any redundancy and performance related issues, especially when searching for a portfolio and so on?
3) Will this be able to scale when I want to add more features later on?
4) Is there a better way to model the system?

Thank You

  • 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-11T18:56:45+00:00Added an answer on May 11, 2026 at 6:56 pm

    You could use a single media and a single portfolio table. Add an extra field that tells you whether it belongs to a User or a Group. Then, don’t add the $belongsTo attribute to your model but use the bindModel method to dynamically attach the correct model.

    Alternatively you chould also use UUIDs (mysql: varchar 36) instead of integers for your IDs. UUIDs never collide. So, you could make Portfolio and Media belongsTo User and group, using the same field. This works because there never will be a User that has the same ID as a Group when you use UUIDs. Example:

    class Media {
        $belongsTo = array(
            'User' => array('foreignKey' => 'parent_id'),
            'Group' => array('foreignKey' => 'parent_id'),
        );
    }
    

    The former is technically more correct. The latter is easier to implement and you may not like the longer URLs that the long UUIDs create.

    Edit: To address your comment about uniqueness, UUIDs are designed to be globally unique. That is, not only will you not have duplicates inside your own database, but there should not be any duplicates in the world. Anywhere.

    See this Wikipedia article about the probability of dupliactes using UUID. The short story: After generating 70,000 billion UUID’s the probability of having just even one duplicate is 4 in 10 billion. You have a better chance of being struck by lightning twice on the same day 🙂

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

Sidebar

Ask A Question

Stats

  • Questions 242k
  • Answers 242k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Assuming the plugin is not released publicly, you will need… May 13, 2026 at 7:34 am
  • Editorial Team
    Editorial Team added an answer If you have problems with the button, it's not going… May 13, 2026 at 7:34 am
  • Editorial Team
    Editorial Team added an answer It says "the event never happened" to the browser. If… May 13, 2026 at 7:34 am

Related Questions

I am creating a class library with many different options for possible customizations. For
I am creating a simple aspnetmvc cart application and have defined classes similar to
I am trying to become a good programming citizen through learning more about Dependency
I have found this tutorial online http://net.tutsplus.com/tutorials/php/creating-a-php5-framework-part-1/ I have created myself a simple sort

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.