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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:29:57+00:00 2026-05-31T03:29:57+00:00

I am designing the database (MySQL) in which I have two tables Employees and

  • 0

I am designing the database (MySQL) in which I have two tables Employees and Guests as following :

CREATE TABLE employee (
`EMP_ID` INT UNSIGNED NOT NULL AUTO_INCREMENT,
 `FIRST_NAME` VARCHAR(8) NOT NULL,
 `MID_NAME` VARCHAR(11), 
`LAST_NAME` VARCHAR(8) NOT NULL,
 `BIRTHDAY` DATE,
 `COUNTRY_ID` INT, 
`NAT_ID` VARCHAR(8) NOT NULL,
 `ID_EXP_DATE` DATE,
 `ID_TYPE` VARCHAR(8) NOT NULL,
 `Mobile` VARCHAR(8) NOT NULL,
 `PHONE` VARCHAR(8) NOT NULL, 
`EMAIL` VARCHAR(27) NOT NULL,
 `DEPT_ID` TINYINT NOT NULL references DEPARTMENT (ID), 
`POSITION` VARCHAR(20), 
`EMP_TYPE` TINYINT NOT NULL references EMP_TYPES (type),
 `JOINDATE` DATE,
 `SALARY` MEDIUMINT DEFAULT 0 ,
 `WORKEMAIL` VARCHAR(30), 
`MARITALSTAT` VARCHAR(7),
 `EMERGCONTACT` VARCHAR(22),
 `EMERG_CONT_PHN` VARCHAR(11), 
`GENDER` VARCHAR(6),
 `RESUMEURL` VARCHAR(60),
 `RELIGION` VARCHAR(11), 
PRIMARY KEY (`EMP_ID`));

CREATE TABLE Guest (
`guest_ID` INT UNSIGNED NOT NULL AUTO_INCREMENT,
 `FIRST_NAME` VARCHAR(8) NOT NULL, 
`MID_NAME` VARCHAR(11),
 `LAST_NAME` VARCHAR(8) NOT NULL, 
`BIRTHDAY` DATE, 
`COUNTRY_ID` INT,
 `NAT_ID` VARCHAR(8) NOT NULL, 
`ID_EXP_DATE` DATE, 
`ID_TYPE` VARCHAR(8) NOT NULL,
 `Mobile` VARCHAR(8) NOT NULL, 
`PHONE` VARCHAR(8) NOT NULL, 
`EMAIL` VARCHAR(27) NOT NULL, 
`WORKEMAIL` VARCHAR(30),
 `MARITALSTAT` VARCHAR(7), 
`EMERGCONTACT` VARCHAR(22),
 `EMERG_CONT_PHN` VARCHAR(11),
 `GENDER` VARCHAR(6),
`RELIGION` VARCHAR(11),
..................................// More attributes specific for guest table
 PRIMARY KEY (`Guest_ID`));

Since both of the tables have auto generated primary keys and it would not be appropriate if they share primary key from person. would it be a good idea to create a table named person with all the common attributes and two child tables as Employee and Guest?
and what would be the best practice to implement this?

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-31T03:29:58+00:00Added an answer on May 31, 2026 at 3:29 am

    There are some things to consider:

    Can an Employee be a Guest or vice versa?
    How to compare them?

    If this plays a role for your application, i´d consider a ParentTable, because so you can easily figure out, if an Employee is also a Guest or not. So you can easily compare them.

    On the other hand, you could do a 3rd Option:
    A Table called Personal Information.
    An Employee has an Reference to this, Guests also.
    If an Employee and an Guest both refeer to the same entry, you know they are the same person.

    Schema:

    yes the schema is like:

    Table:
    PersonalInformation


    ID (Primary Key, auto inc)
    And put all your information here

    Table Employee


    ID (Primary Key, auto inc int)
    PersonalInformation_ID (ForeignKey to PersonalInformation.ID)
    Add your Employee specific columns here

    Table Guest


    ID (Primary Key, auto inc int)
    PersonalInformation_ID (ForeignKey to PersonalInformation.ID)
    Add your Guest specific columns here

    Hope this helps you implement it, otherwise ask again.

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

Sidebar

Related Questions

I am designing a database for a project. I have a table that has
I am designing a database in Mysql which will be filled with quite large
I am designing a website which will query a simple MySQL database using AJAX
I'm designing my database schema using MySQL Workbench, which is pretty cool because you
I am designing an SQL database (accessed via PHP/MySQL) and have questions about designing
I am designing database tables for a master-detail scenario. The specific requirement is that
We're designing a database in which I need to consider some FK(foreign key) constraints.
Assuming that best practices have been followed when designing a new database, how does
The database I'm designing has 3 major tables: BOOKS , ARTICLES , NOTES .
I have a database of events which gets updated every night. A single event

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.