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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:31:47+00:00 2026-06-14T06:31:47+00:00

Following is a table structure in my system. The scenario is, system has Clients.

  • 0

Following is a table structure in my system. The scenario is, system has Clients. Clients can be
many type, for exampel: a Person, a Company, a Bank or etc. I have come with a database design as follows.

TABLE : CLIENT

===============================
| ID    | NAME_CODE | TYPE    |
-------------------------------
| 1000  | Martin    | PERSON  |
| 1002  | George    | PERSON  |
| 1003  | Max_Group | COMPANY |
-------------------------------

TABLE : PERSON

==================================================
|  ID | CLIENT_ID  | FIRST_NAME   | LAST_NAME    |
--------------------------------------------------
| 1   | 1001       | Martin       | XXXXXXXXXXX  |
| 2   | 1002       | George       | XXXXXXXXXXX  |
--------------------------------------------------

TABLE : COMPANY

===================================================
| ID | CLIENT_ID  | NAME           | Location     |
---------------------------------------------------
| 1  | 1003       | Max Group Inc. | XXXXXXXXXXX  |
---------------------------------------------------

EDIT : ID added for PERSON and COMPANY tables.

I welcome if any one could suggest me a better structure.

For the above structure, I need to creat the class model. Following is what I have created.

class Client
{
   int ID;
   string NameCode;
}

class Person : Client
{
    int ID;
    int ClientId;
    string FirstName;
    stirng LastName;
    //........
}

class Company : Client
{
    int ID;
    int ClientId;
    string Name;
    string Location;
    //.........
}

I feel the above model are not suitable. There can be a right way for this.
Please suggest me a better way.

  • 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-14T06:31:48+00:00Added an answer on June 14, 2026 at 6:31 am

    After some discussion, I think your tables are well designed.

    I would design your tables this way:

    TABLE : CLIENT

    ==============================
    | ID   | NAME_CODE | TYPE    |
    ------------------------------
    | 1    | Martin    | 1       |
    | 2    | George    | 1       |
    | 3    | Max_Group | 2       |
    ------------------------------
    

    where Type is an Enum rather than anything hard-coded so that queries are faster.

    TABLE : PERSON

    ============================================
    | CLIENT_ID  | FIRST_NAME   | LAST_NAME    |
    --------------------------------------------
    | 1          | Martin       | XXXXXXXXXXX  |
    | 2          | George       | XXXXXXXXXXX  |
    --------------------------------------------
    

    TABLE : COMPANY

    ==============================================
    | CLIENT_ID  | NAME           | Location     |
    ----------------------------------------------
    | 3          | Max Group Inc. | XXXXXXXXXXX  |
    ----------------------------------------------
    

    And the classes would look like:

    class Client
    {
       int ID;
       string NameCode;
        //........
    }
    
    class Person : Client
    {
        string FirstName;
        stirng LastName;
        //........
    }
    
    class Company : Client
    {
        string Name;
        string Location;
        //.........
    }
    

    The Client table has the parent id now for every client entity. It could have been reversed by having individual id for persons and banks and then reference a foreign key in the parent client table which I believe is easier to operate from db point of view (that scales well if you’re going for composition). But in the application I love inheritance and polymorphism, so the straight adaptation of it for db design is what I posted.

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

Sidebar

Related Questions

I have the following MySQL table structure: num field company phone website 1 Gas
Following is the table structure: desc customer_survey Name Null Type ----------- -------- ------------ SURVEYID
I'm trying to build a modified role system that has the following class/relationship structure:
I have a XML structure like the following: <Root> <Node Name=File System> <Node Name=C:\Windows\System32\drivers\etc\hosts>
I have a database structure that has a Person table which contains fields such
I have the following table structure: ID | fname | lname | street |
I have the following table structure inside a view which gets displayed in the
I have the following table structure: ORGANIZATION_ID | Name | PARENT_ID -------------------------------------------------- 1 |
I have the following table structure (in MySQL): DocID, Code, IsDup, DopOf , where
I have the following table structure. A | B | C I wish to

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.