CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 employee multiple departments

Print topic Send  topic

Author Message
makande777

Posts: 9
Posted: 11/08/2007, 9:34 AM

Hi,

Is it possible to program the employee directory to have multiple departments for each employee. I would like to have the results of employees that are affilliated with more than one department show up in a search.

What would need to be done to acomplish this?

Thanks
Michael
View profile  Send private message
ckroon

Posts: 869
Posted: 11/08/2007, 12:58 PM

That should be quite simple.

Add the fields in your database: dept2 dept3 and dept 4
Then just add those fields to the record and grid forms.
YOu can do searches like this;

Where dept1 = s_dept
OR
dept2 = s_dept
OR
dept3 = s_dept
OR
dept_4 = s_dept


_________________
Walter Kempees...you are dearly missed.
View profile  Send private message
makande777

Posts: 9
Posted: 11/10/2007, 12:19 AM

Im lost. If my database looks like this;

);

CREATE TABLE departments (
department_id integer auto_increment primary key,
department_name varchar(50) NULL,
department_manager_id integer NULL
);


CREATE TABLE employees (
emp_id integer auto_increment primary key,
emp_login varchar(50) NULL,
emp_password varchar(50) NULL,
emp_name varchar(50) NULL,
title varchar(50) NULL,
group_id integer NULL,
department_id integer NULL,
phone_home varchar(50) NULL,
phone_work varchar(50) NULL,
phone_cell varchar(50) NULL,
fax varchar(50) NULL,
email varchar(50) NULL,
city varchar(50) NULL,
zip varchar(50) NULL,
address varchar(50) NULL,
picture varchar(50) NULL
);

Do I add;

depart2 integer NULL,

in the employees table??
View profile  Send private message
wkempees
Posted: 11/10/2007, 4:18 AM

It is not best-practice but yes you can add a
department2_id, department3_id and department4_id
to your employees table.
all field settings the same as department_id.
You would then in your form add these fields to your record and make all the
lookups function.

This would solve your immediate requirement.
And make Ckroon's solution viable.

Database design would imply creating a many-to-many table schema.
Walter

makande777

Posts: 9
Posted: 11/10/2007, 1:58 PM

What would be considered best practice for this type of solution??
View profile  Send private message
ckroon

Posts: 869
Posted: 11/10/2007, 8:35 PM

Another approach, which I think is waht Walter is alluding to, is to make a "Department _Assigned" table which consists of hte Employee ID and the departments he/she is assigned to.



_________________
Walter Kempees...you are dearly missed.
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.