473,321 Members | 1,669 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

Schema set up issue

In my Access 2000 database, how do I build an efficient schema where a
Project can have multiple workers and I need to store each worker first
name, last name, email and phone number?? So if a Project has 3
workers then I need to store all three workers information with that
Project.

Here is how I have my tables now but there must be a better way??

Project Table:
projectID - Primary Key
workerID - Foreign Key
projectRequirement
projectPriority

Worker Table:
workerID - Primary Key
worker1FirstName
worker1LastName
worker1Phone
worker1Email
worker2FirstName
worker2LastName
worker2Phone
worker2Email
worker3FirstName
worker3LastName
worker3Phone
worker3Email

Nov 13 '05 #1
5 1341
On 5 Aug 2005 20:33:50 -0700, te****@hotmail.com wrote:

You need three tables. Realize that the relationships are: each
project can have multiple workers, and each worker works on multiple
projects. That's classic many-to-many, which in a relational database
we express in 3 tables:
Project table: same as yours, without workerID
Worker table: same as yours
New table WorkersOnProjects: workerID, projectID, with a PrimaryKey
over both fields. This table could have additional fields, such as
DateStarted (the date this worker started working on this project),
etc.

-Tom.

In my Access 2000 database, how do I build an efficient schema where a
Project can have multiple workers and I need to store each worker first
name, last name, email and phone number?? So if a Project has 3
workers then I need to store all three workers information with that
Project.

Here is how I have my tables now but there must be a better way??

Project Table:
projectID - Primary Key
workerID - Foreign Key
projectRequirement
projectPriority

Worker Table:
workerID - Primary Key
worker1FirstName
worker1LastName
worker1Phone
worker1Email
worker2FirstName
worker2LastName
worker2Phone
worker2Email
worker3FirstName
worker3LastName
worker3Phone
worker3Email


Nov 13 '05 #2
Oooh... looks like you need a crash course in normalization. You might
want to search the web for tutorials on it.

Standard schema for this is something like:

CREATE TABLE Project(
ProjectID INTEGER PRIMARY KEY,
PName TEXT(20) NOT NULL,
Priority INTEGER);

CREATE TABLE Employee(
EmployeeID INTEGER PRIMARY KEY,
FirstName TEXT(15) NOT NULL,
LastName TEXT(15) NOT NULL,
EMail TEXT(50),
Phone TEXT(10).
DeptID INTEGER,
FOREIGN KEY (DeptID) REFERENCES Department(DepartmentID)
);

CREATE TABLE WorksOn(
EmpID INTEGER,
ProjID INTEGER,
Hours NUMBER(3,2),
PRIMARY KEY (EmpID, ProjID)
FOREIGN KEY EmpID REFERENCES Employee(EmployeeID),
ProjID REFERENCES Project(ProjectID)
);

Nov 13 '05 #3
You're right: there is a better way, and this was an important question to
ask.

Keep your Project table.
Simplify your Worker table so it copes with just one person.

Add a 3rd table with fields:
ProjectID relates to Project.ProjectID
WorkerID relates to Worker.WorkerID
AssignDate Date this worker was assigned to this project.
EndDate Date the worker finished working on this project.
Typically it would be named ProjectWorker.

The 3rd table then contains one record for every combination of project +
worker. So if there are 3 workers on project 2, there will be 3 records in
the table. If there are also 5 workers on project 2, that's another 5
records.

The interface will consist of:
- A main form bound to the Project table.
- A subform bound to the ProjectWorker table.
The subform would contain a combo box for selecting the worker (i.e. its
RowSource is the Worker table.), and you select multiple workers on multiple
rows.

The 3rd table is called a junction table, and it is the standard way to
resolve a many-to-many relation. Whenever you see repeating fields such as
Worker1, Worker2, ... you need a junction table instead. For another
example, see:
Relationships between Tables (School Grades example)
at:
http://allenbrowne.com/casu-06.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<te****@hotmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
In my Access 2000 database, how do I build an efficient schema where a
Project can have multiple workers and I need to store each worker first
name, last name, email and phone number?? So if a Project has 3
workers then I need to store all three workers information with that
Project.

Here is how I have my tables now but there must be a better way??

Project Table:
projectID - Primary Key
workerID - Foreign Key
projectRequirement
projectPriority

Worker Table:
workerID - Primary Key
worker1FirstName
worker1LastName
worker1Phone
worker1Email
worker2FirstName
worker2LastName
worker2Phone
worker2Email
worker3FirstName
worker3LastName
worker3Phone
worker3Email

Nov 13 '05 #4
On Fri, 05 Aug 2005 20:53:35 -0700, Tom van Stiphout
<no*************@cox.net> wrote:

Oops, sorry, I did not read the structure of your Worker table well.
It should have only these fields:
workerID - Primary Key
workerFirstName
workerLastName
workerPhone
workerEmail

Thanks, Pieter, you got it right the first time.

-Tom.

On 5 Aug 2005 20:33:50 -0700, te****@hotmail.com wrote:

You need three tables. Realize that the relationships are: each
project can have multiple workers, and each worker works on multiple
projects. That's classic many-to-many, which in a relational database
we express in 3 tables:
Project table: same as yours, without workerID
Worker table: same as yours
New table WorkersOnProjects: workerID, projectID, with a PrimaryKey
over both fields. This table could have additional fields, such as
DateStarted (the date this worker started working on this project),
etc.

-Tom.

In my Access 2000 database, how do I build an efficient schema where a
Project can have multiple workers and I need to store each worker first
name, last name, email and phone number?? So if a Project has 3
workers then I need to store all three workers information with that
Project.

Here is how I have my tables now but there must be a better way??

Project Table:
projectID - Primary Key
workerID - Foreign Key
projectRequirement
projectPriority

Worker Table:
workerID - Primary Key
worker1FirstName
worker1LastName
worker1Phone
worker1Email
worker2FirstName
worker2LastName
worker2Phone
worker2Email
worker3FirstName
worker3LastName
worker3Phone
worker3Email


Nov 13 '05 #5
_straight_ out of my DB1 textbook <grin>, hence the Oracle-style table
definitions...

Nov 13 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Olaf Meyer | last post by:
Apprentently xerces 2.6.0 (Java) does not validate against contraints specified in the schema (e.g. constraints specified via unique element). The validation works with the XML editor I'm using...
1
by: eXavier | last post by:
Hi, I need to validate XML fragment against XSD schema. The main issue is that xml fragment does not contain refrence to schema, but I want to force the validation against the schema I have in...
2
by: Steven (dotnet newbie) | last post by:
Hello. I am trying to create a database from an XML file. I am able to create a dataset from the XML doc, but how can I create a database schema from the dataset and populate the database? Or is...
2
by: Rajesh Jain | last post by:
I Have 2 separate schemas. --------------Schema 1 is defined as below----------- <xs:schema targetNamespace="http://Schemas/1" xmlns="http://Schemas/1" xmlns:xs="http://www.w3.org/2001/XMLSchema"...
4
by: bibsoconner | last post by:
Hi, I hope someone can please help me. I'm having a lot of trouble with schema files in .NET. I have produced a very simple example that uses "include" to include other schema files. It all...
13
by: Martin Z | last post by:
I'm making a CRUD screen for an Oracle database... but problem is that the primary key in that table is populated via an autonumber, which in Oracle is done just with triggers and sequences. ...
9
by: mstilli | last post by:
Hi, I am trying to use schema for server side validation using xerces to catch the validation errors. validating this XML: <Content4> <textarea13></textarea13>...
3
by: dantohester | last post by:
Hi there, I have the following situation: I want to create an XML document that contains 2 parts: a) a XHTML part (it can be either version 1.0 or 1.1 ) b) a non XHTML part that contains some...
0
by: Durango2008 | last post by:
Hi I am having a hard time with validation of my XML file with given schema. Here are the files: roboerrorlog.xsd <robomss:schema xmlns:robomss="http://www.w3.org/2001/XMLSchema"...
3
by: TOUDIdel | last post by:
I define element wihout certaint type declaration (there aren't type attribute, complex or simple type child): e.g. ... <xs:element name="invoice"/> ... MSXML doesn't report any errors when...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.