I am developing a online job portal website. In class diagram I generalized Employer & Employee as Members class & I put 'MID' as primary key. Now I am confused how to create tables for Employer & Employee?
Here is tables you required:
Member
========
Id (or MId) (PK)
... (Specifications you need)
Employer
========
Id (PK)
MId (FK to Member table)
... (Specifications you need)
Employee
========
Id (PK)
MId (FK to Member table)
EId (FK to Employer table)
... (Specifications you need)
Related
Suppose I have employees and departments and employee role where one employee can belong to a different department with a different role.
For example, Emp 1 belongs to Dept 1 with a role manager. where the same employee can belong to Dept 2 with a role service-man.
Each employee also has a child hierarchy like Emp 2, Emp 3 belongs to Dept 1 with role assistant and their parent is Emp 1.
In this case what will be the best solution for designing this concept. Please share your opinion.
Consider the entities and attributes:
Employees:
id,
name
Departments:
deptID,
dept_name
Roles:
role_id,
role_name
I'll try to state the business domain as you've outlined it, and then turn that into a schema suggestion.
The system has 0 or more employees
The system has 0 or more departments
The system has 0 or more roles
<<EDIT: your comment says that the "parent" role is department-specific>>
An employee belongs to 1 or more departments, and within that department has exactly one role and one parent (a parent is another employee)
Employee
------------
Employee_id (pk)
Name
Roles
------
Role_id (pk)
Name
Departments
-----------
Department_id (pk)
Name
Employee_deparment_role
-------------------------
employee_id (pk, fk)
department_id (pk, fk)
role_id (pk, fk)
Parent_id (pk, fk to employees)
This model only captures one state - it doesn't allow people to change departments or roles, or "parent", but you didn't mention that as a requirement.
I have the following db structure and am wanting to add in a new table called notepad:
ClinicTable (Id PK)
PatientTable (Id PK, ClinicId PK FK)
DoctorTable (Id PK, ClinicId PK FK)
ConsultationTable( Id PK, ClinicId PK FK, PatientId FK, DoctorId FK)
I'm waiting to hear back re: the business requirement, but the
notepad could either be tied to the consultation (1 to 1) or tied to
the patient (1 to M).
We are slowly restructuring and refactoring as
part of a new product build so I don't want to add the note to the
consultation table - I'd prefer to store it separately
A patient or consultation may or may not have a
notepad record, but a notepad record cannot exist without a patient
or a consultation.
A notepad record will always be entered by a single doctor and cannot be owned
by any other doctor
How do I determine whether to make the relationships identifying or non-identifying?
All of the other tables have the clinic Id in them, but I don't see that I need that?
I'm thinking it should look like the following...
If the note is tied to the patient then I have:
NotepadTable (Id PK, PatientId PK FK, DoctorId PK FK)
If the note is tied to the consultation then I have:
NotepadTable (Id PK, ConsultationId PK FK)
Wondering if you think the following table for storing employees in a database would be consider a database in BCNF ?
- Employee Table
Employee_ID (Primary Key, unique)
First_Name
Surname
Religion
Sex
Job Title
Nationality
- Employee_Address Table
Employee_ID (Foreign Key)
Line_One_Address
Line_Two_Address
District
Country
- Employee_Conact Table
Employee_ID (Foreign Key)
Mobile_Number
So my question is do you think this will meet the critria for being in BCNF ? Or should I have a Nationaility table, Job Title Table, Religion table etc. as they will be duplicate information in the db for it
I am just new to the learning normilzation, so any thoughts and tips will be helpful
i would suggest renaming the EMPLOYEE table to PERSON
then you will notice that job title does not belong with the person definiton- so at least that one should be in another table - like a linking table between people and organizations - where you would put the title and hire date etc.
I have three tables:
student
id (pk)
name
course
id (pk)
course_name
course_duration
course_fee
student_course
student_course_id (pk)
student_id (fk)
course_id (fk)
If after a certain period of time course fee changes then how can I maintain the record of student having previous course fee?
Logically you copy it into the enrolments table (student_course). This supposes that the price will not change after the registration.
I need to create an ER where users can add and delete their personal contacts.
Contacts can be any person including other users.
Users can also check who of the other users have added them to their contact list.
I don't know how to start. Can someone please help me draw this ER?
Person
PersonID (PK)
OtherUserInfo...
Contact
PersonId (FK to UserID)
contactId (FK to ContactID) Composite PK these 2 together.
PersonProfile
PersonID (FK to userID)
PersonCategoryID (FK to UserCategoryID) Composite PK these 2 together.
PersonCategory
personCategoryID (PK)
PersonCategory (User, Contact etc) depending on if a user can be a contact or just a contact or just a user.
when a user adds a contact the entry is put in Person table and an associated record is in personProfile with a personcategoryID for contact and the contact is linked to the person putting in the etnry via contact table
If a person is added as a contact from the other users, (found by joining person to personprofile where personcategory links to "user" entry, then an entry is saved in contact with the personId doing the seach and the personid of the contact they just added.
if a person is removed from personporfile as a contact, all entries in contact table for that contactId are removed as that person is no longer a valid contact. (assuming history isn't needed)
Just my thoughts... there's lots of ways to skin this cat based on additional requirements, desired growth etc.