1,105,423 Community Members

What to do?

Member Avatar
chdboy
Junior Poster
114 posts since Aug 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

I'm making a payroll software ,I have made two forms

1.Employer Form
2.Employees form

I think now that I have confused ,because now I cannot diffrenciate between who works for who

any sugesstions how can I improve on design ,or something that can solve the confusion (Problem)
I also have two seperate tables for both employer and employees

Thanks in Advance

Member Avatar
Reverend Jim
Noli mentula
5,444 posts since Aug 2010
Reputation Points: 746 [?]
Q&As Helped to Solve: 653 [?]
Skill Endorsements: 51 [?]
Moderator
Featured
 
0
 

You haven't posted the structure of the tables so a definitive answer isn't possible, however I suspect you haven't related the tables. Your Employer table will need at least two fields such as

Employer
EmployerID (identity)
EmployerName (varchar)

And the Employee table will need the same type of fields plus it must contain the field, EmployerID so that each EmployeeName record relates to a record in the Employer table. The EmployerID field in the Employer table will be either an integer (auto-increment) or a GUID value. In a real-world situation, EmployerName would actually be broken down into separate fields such as FirstName, MiddleName and LastName.

Member Avatar
chdboy
Junior Poster
114 posts since Aug 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Yes you are right I have not related the tables
here is the screen shot of the structure of tables

Employee_tableEmployer_table

Attachments
Member Avatar
Reverend Jim
Noli mentula
5,444 posts since Aug 2010
Reputation Points: 746 [?]
Q&As Helped to Solve: 653 [?]
Skill Endorsements: 51 [?]
Moderator
Featured
 
0
 

You'll have to add the EmployerID field to the Employee table in order to link the two tables. Also, what are the definitions of Firstname & Lastname as applied to an employer? For example, I used to work for Manitoba Hydro, which would be entered under CompanyName (which is not a required field???). No one person owns that company so what gets entered for Firstname/Lastname? Only Lastname is a required field. Firstname is not. Yet in the employee table only the ID is required which is pointless because an employee must have a name. You still have some thinking to do.

Member Avatar
chdboy
Junior Poster
114 posts since Aug 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

I have added a new Field in the Employee table as you can see in this screenshot attached
and I'm preparing this software for the small firm not a big company,so first name and last name is required,and I have the companyname field in Employer table also.
Now how to relate the two tables? Employee_table_1

Attachments
Member Avatar
Reverend Jim
Noli mentula
5,444 posts since Aug 2010
Reputation Points: 746 [?]
Q&As Helped to Solve: 653 [?]
Skill Endorsements: 51 [?]
Moderator
Featured
 
0
 

You will also have to define EmployerID in the Employee table as a foreign key and you can define a contraint to ensure that it exists in the Employer table. How you do this depends on your DBMS. I use MS SQL but because my dev system is in for repairs I can't give you instructions on how to set this up at the moment.

You will also have to decide which fields are required and deselect the Allow NULLS option.

Member Avatar
chdboy
Junior Poster
114 posts since Aug 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

You mean both my two table have EmployerID as a field and make it a Foreign Key and deselect Allow nulls options in both the tables for the specific fields?

Member Avatar
chdboy
Junior Poster
114 posts since Aug 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Actually Both my tables have the field ID and both I have added as FK to it .

Member Avatar
Reverend Jim
Noli mentula
5,444 posts since Aug 2010
Reputation Points: 746 [?]
Q&As Helped to Solve: 653 [?]
Skill Endorsements: 51 [?]
Moderator
Featured
 
0
 

Both your tables have a field named ID, but in the Employee table it is the Employee ID and in the Employer table it is the Employer ID. Each record in the Employee table has to be associated with an employer. You do this by ensuring that each record contains the Employer ID.

Member Avatar
chdboy
Junior Poster
114 posts since Aug 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

I get when I try to click the option Allow Nulls

'Employee' table
- Unable to modify table.  
Cannot insert the value NULL into column 'EmployerID
Member Avatar
chdboy
Junior Poster
114 posts since Aug 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

I have added a FK(Foreign Key) to my Employee Table ,now what next? FK_relationship_Employee_table

Attachments
Member Avatar
chdboy
Junior Poster
114 posts since Aug 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

And my Employer table has the same field and column set as PK(Primary Key) NOT set as FK(Foreign Key)

Question Answered as of 1 Year Ago by Reverend Jim
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article