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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:44:48+00:00 2026-05-23T22:44:48+00:00

Due to CakePHP limitation to only use User as the road to go in

  • 0

Due to CakePHP limitation to only use User as the road to go in Auth, I have to change my user type setup. I have tried some fancy code to overwrite the identify() method in the Auth component but that did not solve the problem. I use a Role field to distinguish between premium and standard users.

I have Users and Companies that need to login and perform actions separately. Why not 1 user table with a usertype field? Because they have 75% different fields inside the table.

In my new setup, I have 1 User table and a HasOne relationship with a Company or a Member (former User table). Inside the User table, the common fields reside including the email address and password for login (to tackle the Auth force to use User).

It looks like this:

Table users:

  • id
  • name
  • email
  • password
  • member_id, NULL (FK)
  • company_id, NUll (FK)
  • role_id (FK)

Table member

  • id
  • specific field x
  • specific field y
  • …

Table companies

  • id
  • specific field a
  • specific field b
  • …

The ugly thing is that the User table will always have a Null, as a user is a Member or a Company

ANOTHER solution could be to point the FK to the other side. Hereby, the user_id will be the foreign key in the Member and Companies table.

Table users:

  • id
  • name
  • email
  • password
  • role_id (FK)

Table member

  • user_id (FK / PK)
  • specific field x
  • specific field y
  • …

Table companies

  • user_id (FK / PK)
  • specific field a
  • specific field b
  • …

I am stuck and don’t have the normalization & database design experience to choose between the options. Or maybe there both solutions are terrible and another solution should be it.
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-23T22:44:49+00:00Added an answer on May 23, 2026 at 10:44 pm

    well you should use the groups table to handle user types, i.e. one user table with common fields like username and password and a foreign key belonging to the groups table, and one table for groups groups table could have different types of group like normal_user or company. This way you will be able to handle as many different user types as you want. And even if you have many different fields for each type of user you can make separate tables for them (If you have only 2-3 user types witch are absolutely different) like company_details user_details and add fields specific to that type of user in them, and include one foreign key along with a type field in groups table. Now groups table will have details_id from either details table. You can select the specific data based on the type field in groups i.e. if the type is normal_user join with user_detail table else if it is company join with company table. But you will have to do some manual work because cake wouldn’t be able to join groups table properly.

    Table: groups
    id, details_id(Not unique), type, name, other_fields…

    Table: users
    id, group_id, username, password, other_fields…

    Table company_detail
    id, specific fields…
    Other Groups tables

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

Sidebar

Related Questions

Due to testing and time measuring I have to write some kind of log
Due to an older version of MySQL I'm having to use some pretty outdated
Due to a rather brilliant oversight in my current project, we have some guids
Due to an incident a few months prior, thousands of author_ids have been deleted
Due to some css limitations between IE and the rest of the world I
Due to a number of constraints that I won't get into, I have to
I can't seem to figure this one out. I have a validator-type script that
Due to some caching issues, I need to explicitly bypass the cache, for a
Due to a customer requirement I am forced to use classic ASP, so I
We have an old (written in CakePHP 1.1!) application that has started groaning under

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.