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

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.

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

Employee_tableEmployer_table

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.

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

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.

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?

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

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.

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

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.