0

I have two types of users. For example:

  1. Male 2 Female

Now I have created a table of 'users' that holds all the common information and 'males' and 'females' will hold specific information related to those.

Now my question is how to create the table for males and females. Do they will hold the user_id column. If so, then hypothetically, a user can have multiple male or female accounts. How to solve this issue?

1 Answers1

1

Why don’t you just add a column, ‘gender’, in the users table? It will take just 1 character to describe if a person is male (‘M’) or female (‘F’).

If you insist on creating a new table anyway, you can define the user_id column as unique in the new table and it should be a foreign key that refers to the user_id column of the users table.

  • Even if I use unique constraint Since I have two tables one for male and another for female. One user id X can be both in male or female table I can stop that using validation. But I want learn the right architecture approach. – Istiyak Sheyam Jun 28 '22 at 21:01
  • @IstiyakSheyam - The right architecture would be to use only one table. – Rohit Gupta Jul 02 '22 at 01:28