I'm a beginner in development. I'm breaking my head and I'm confused as to the problem below.
an employee can be a programmer or analyst
Programmer
- name
- sex
- age
- programming language
Analyst
- name
- sex
- age
- Project
I'm a beginner in development. I'm breaking my head and I'm confused as to the problem below.
an employee can be a programmer or analyst
Programmer
Analyst
You can have a row associated with each Employee that stores the Foreign key of whether the employee is an Analyst or a Programmer.
E.g.
Employee
- id
- Name
- Sex
- Age
- Type_Id
Types
- id
- Type
Example Data:
Types
- 1, Programmer
- 2, Analyst
Employee
- 1, "Sid", "Male", 25, 1
- 2, "Sandra", "Female", 28, 2
With this approach, if more roles are added in future, you can just add it to master table Types
and refer it from Employee
Table.
Use foreign keys.
So if you have an Employee table, you can connect them likes this:
Employee
id
name
sex
age
Programmer
employeeId
Analyst
employeeId
EmployeeId
will refer to a row inside the Employee table with a matching id
column