A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Table Normalization



 
 
Thread Tools Display Modes
  #1  
Old December 12th, 2004, 12:49 AM
Jonathan Brown
external usenet poster
 
Posts: n/a
Default Table Normalization

I didn't normalize my database as well as I wish I had. I have a table
called EmpInfo that's built essentially as follows:

Emp#
HomePhone
CellPhone
BusinessPhone

What I would likek to do I build a different table called EmpPhones that
would like like this:

Emp# (this field would be related to the Emp# field in table EmpInfo)
Phone#
Type (the type field would be a lookup to another table with a list of
different types of phone number)

The Emp# and Phone# fields together would make up my multiple field primary
key.

How would I combine the the HomePhone, Cellphone, and BusinessPhone into one
column, and then have 2 other columns with it's associated Emp# and Type?

Any suggestions would be greatly appreciated.

  #2  
Old December 12th, 2004, 02:21 AM
Ken Snell [MVP]
external usenet poster
 
Posts: n/a
Default

Build the new tables EmpPhones and the PhoneTypes. Decide the numbers that
will be used for the three types of phones.

Then run three append queries, one for each of the phone types. The
following example assumes that the ID value of 1 corresponds to a home phone
type:

INSERT INTO EmpPhones
([Emp#], [Phone#], PhoneTypeID)
SELECT [Emp#], [HomePhone], 1
FROM EmpInfo;

Then modify as needed for the other two types and run them separately.
--

Ken Snell
MS ACCESS MVP



"Jonathan Brown" Jonathan wrote in message
...
I didn't normalize my database as well as I wish I had. I have a table
called EmpInfo that's built essentially as follows:

Emp#
HomePhone
CellPhone
BusinessPhone

What I would likek to do I build a different table called EmpPhones that
would like like this:

Emp# (this field would be related to the Emp# field in table EmpInfo)
Phone#
Type (the type field would be a lookup to another table with a list of
different types of phone number)

The Emp# and Phone# fields together would make up my multiple field

primary
key.

How would I combine the the HomePhone, Cellphone, and BusinessPhone into

one
column, and then have 2 other columns with it's associated Emp# and Type?

Any suggestions would be greatly appreciated.



  #3  
Old December 12th, 2004, 02:30 AM
'69 Camaro
external usenet poster
 
Posts: n/a
Default

Hi, Jonathan.

Any suggestions would be greatly appreciated.


You may want to look even further ahead in your organization's needs for
this database, such as how many other types of phone numbers are likely to
be added. Pagers come to mind.

I suggest taking these five steps:

1.) Create a table for the types of phone numbers. Add an Autonumber
primary key and the "PhoneType" field to hold the name of the phone type.
It might look like this:

Table: tblPhoneTypes

PTID PhoneType
1 Business
2 Cell
3 Home
4 Pager

2.) Create a query that gathers the information from the EmpInfo table in a
normalized structure and name this query qryEmpPhones:

SELECT EmpNum, HomePhone AS PhoneNum, 3 AS PTID
FROM EmpInfo
UNION
SELECT EmpNum, CellPhone, 2 AS PTID
FROM EmpInfo
UNION SELECT EmpNum, BusinessPhone, 1 AS PTID
FROM EmpInfo;

3.) Create a make table query with the following SQL statement:

SELECT * INTO tblEmpPhones
FROM qryEmpPhones
ORDER BY EmpNum, 3;

4.) Open the tblEmpPhones table and edit the field defaults (such as size
of the text field), assign the primary key, open the table properties and
change the Subdatasheet Name combo box to [None], then save the new table.

5.) Open the Relationships window and create the relationship between the
tblEmpPhones and tblPhoneTypes tables, then save the change to the
Relationships window.

I'd also suggest not using special keys, like # and spaces in field names
and table names to avoid bugs later. You may even want to add an additional
field to the tblEmpPhones table to indicate which phone number is the
primary phone number to reach the employee at.

HTH.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)


"Jonathan Brown" Jonathan wrote in message
...
I didn't normalize my database as well as I wish I had. I have a table
called EmpInfo that's built essentially as follows:

Emp#
HomePhone
CellPhone
BusinessPhone

What I would likek to do I build a different table called EmpPhones that
would like like this:

Emp# (this field would be related to the Emp# field in table EmpInfo)
Phone#
Type (the type field would be a lookup to another table with a list of
different types of phone number)

The Emp# and Phone# fields together would make up my multiple field

primary
key.

How would I combine the the HomePhone, Cellphone, and BusinessPhone into

one
column, and then have 2 other columns with it's associated Emp# and Type?

Any suggestions would be greatly appreciated.



  #4  
Old December 12th, 2004, 03:09 AM
Jonathan Brown
external usenet poster
 
Posts: n/a
Default

Ken,

Your suggestion is working well except for one thing, and I think it is
probably because of problems with my own database but when I run the query it
displays an error message saying "it didn't add 46 records to the tabel due
to key violations."

What do you suppose that might mean?

Thanks
Jonathan
"Ken Snell [MVP]" wrote:

Build the new tables EmpPhones and the PhoneTypes. Decide the numbers that
will be used for the three types of phones.

Then run three append queries, one for each of the phone types. The
following example assumes that the ID value of 1 corresponds to a home phone
type:

INSERT INTO EmpPhones
([Emp#], [Phone#], PhoneTypeID)
SELECT [Emp#], [HomePhone], 1
FROM EmpInfo;

Then modify as needed for the other two types and run them separately.
--

Ken Snell
MS ACCESS MVP



"Jonathan Brown" Jonathan wrote in message
...
I didn't normalize my database as well as I wish I had. I have a table
called EmpInfo that's built essentially as follows:

Emp#
HomePhone
CellPhone
BusinessPhone

What I would likek to do I build a different table called EmpPhones that
would like like this:

Emp# (this field would be related to the Emp# field in table EmpInfo)
Phone#
Type (the type field would be a lookup to another table with a list of
different types of phone number)

The Emp# and Phone# fields together would make up my multiple field

primary
key.

How would I combine the the HomePhone, Cellphone, and BusinessPhone into

one
column, and then have 2 other columns with it's associated Emp# and Type?

Any suggestions would be greatly appreciated.




  #5  
Old December 12th, 2004, 03:13 AM
Jonathan Brown
external usenet poster
 
Posts: n/a
Default

Nevermind, I answered that question myself. It's because some of the fields
(65 of them) are blank. To verify this I went ahead and ran the append query
and it ended up eppending only 119. I then created a select query that
pulled Emp#, and HomePhone and added the "is not null" criteria under the
HomePhone and it came up with 119 records. So apparently everything is cool.

Thanks Ken

"Jonathan Brown" wrote:

Ken,

Your suggestion is working well except for one thing, and I think it is
probably because of problems with my own database but when I run the query it
displays an error message saying "it didn't add 46 records to the tabel due
to key violations."

What do you suppose that might mean?

Thanks
Jonathan
"Ken Snell [MVP]" wrote:

Build the new tables EmpPhones and the PhoneTypes. Decide the numbers that
will be used for the three types of phones.

Then run three append queries, one for each of the phone types. The
following example assumes that the ID value of 1 corresponds to a home phone
type:

INSERT INTO EmpPhones
([Emp#], [Phone#], PhoneTypeID)
SELECT [Emp#], [HomePhone], 1
FROM EmpInfo;

Then modify as needed for the other two types and run them separately.
--

Ken Snell
MS ACCESS MVP



"Jonathan Brown" Jonathan wrote in message
...
I didn't normalize my database as well as I wish I had. I have a table
called EmpInfo that's built essentially as follows:

Emp#
HomePhone
CellPhone
BusinessPhone

What I would likek to do I build a different table called EmpPhones that
would like like this:

Emp# (this field would be related to the Emp# field in table EmpInfo)
Phone#
Type (the type field would be a lookup to another table with a list of
different types of phone number)

The Emp# and Phone# fields together would make up my multiple field

primary
key.

How would I combine the the HomePhone, Cellphone, and BusinessPhone into

one
column, and then have 2 other columns with it's associated Emp# and Type?

Any suggestions would be greatly appreciated.




  #6  
Old December 12th, 2004, 05:28 AM
tina
external usenet poster
 
Posts: n/a
Default

hey, Gunny, just checked out your website. very nice - it joined mvps.org,
lebans.com, granite.ab.ca, and all the other Access bookmarks in my browser.
the article on marketing was especially interesting, and very entertaining
too! btw, we're neighbors, i'm in so cal also.


"'69 Camaro" AM wrote in
message ...
Hi, Jonathan.

Any suggestions would be greatly appreciated.


You may want to look even further ahead in your organization's needs for
this database, such as how many other types of phone numbers are likely to
be added. Pagers come to mind.

I suggest taking these five steps:

1.) Create a table for the types of phone numbers. Add an Autonumber
primary key and the "PhoneType" field to hold the name of the phone type.
It might look like this:

Table: tblPhoneTypes

PTID PhoneType
1 Business
2 Cell
3 Home
4 Pager

2.) Create a query that gathers the information from the EmpInfo table in

a
normalized structure and name this query qryEmpPhones:

SELECT EmpNum, HomePhone AS PhoneNum, 3 AS PTID
FROM EmpInfo
UNION
SELECT EmpNum, CellPhone, 2 AS PTID
FROM EmpInfo
UNION SELECT EmpNum, BusinessPhone, 1 AS PTID
FROM EmpInfo;

3.) Create a make table query with the following SQL statement:

SELECT * INTO tblEmpPhones
FROM qryEmpPhones
ORDER BY EmpNum, 3;

4.) Open the tblEmpPhones table and edit the field defaults (such as size
of the text field), assign the primary key, open the table properties and
change the Subdatasheet Name combo box to [None], then save the new table.

5.) Open the Relationships window and create the relationship between the
tblEmpPhones and tblPhoneTypes tables, then save the change to the
Relationships window.

I'd also suggest not using special keys, like # and spaces in field names
and table names to avoid bugs later. You may even want to add an

additional
field to the tblEmpPhones table to indicate which phone number is the
primary phone number to reach the employee at.

HTH.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)


"Jonathan Brown" Jonathan wrote in

message
...
I didn't normalize my database as well as I wish I had. I have a table
called EmpInfo that's built essentially as follows:

Emp#
HomePhone
CellPhone
BusinessPhone

What I would likek to do I build a different table called EmpPhones that
would like like this:

Emp# (this field would be related to the Emp# field in table EmpInfo)
Phone#
Type (the type field would be a lookup to another table with a list of
different types of phone number)

The Emp# and Phone# fields together would make up my multiple field

primary
key.

How would I combine the the HomePhone, Cellphone, and BusinessPhone into

one
column, and then have 2 other columns with it's associated Emp# and

Type?

Any suggestions would be greatly appreciated.





  #7  
Old December 12th, 2004, 06:31 AM
'69 Camaro
external usenet poster
 
Posts: n/a
Default

Hi, Tina.

Glad you liked it! I'll tell the other consultants here, because that makes
three people who've bookmarked our site! (Just kidding. We're up to five
now. ;-) )

Have your ears been burning? Your name came up in a discussion here the
other day. (Don't worry. These were favorable remarks.) Where are you in
L.A.? The Valley?

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)


"tina" wrote in message
...
hey, Gunny, just checked out your website. very nice - it joined mvps.org,
lebans.com, granite.ab.ca, and all the other Access bookmarks in my

browser.
the article on marketing was especially interesting, and very entertaining
too! btw, we're neighbors, i'm in so cal also.


"'69 Camaro" AM wrote

in
message ...
Hi, Jonathan.

Any suggestions would be greatly appreciated.


You may want to look even further ahead in your organization's needs for
this database, such as how many other types of phone numbers are likely

to
be added. Pagers come to mind.

I suggest taking these five steps:

1.) Create a table for the types of phone numbers. Add an Autonumber
primary key and the "PhoneType" field to hold the name of the phone

type.
It might look like this:

Table: tblPhoneTypes

PTID PhoneType
1 Business
2 Cell
3 Home
4 Pager

2.) Create a query that gathers the information from the EmpInfo table

in
a
normalized structure and name this query qryEmpPhones:

SELECT EmpNum, HomePhone AS PhoneNum, 3 AS PTID
FROM EmpInfo
UNION
SELECT EmpNum, CellPhone, 2 AS PTID
FROM EmpInfo
UNION SELECT EmpNum, BusinessPhone, 1 AS PTID
FROM EmpInfo;

3.) Create a make table query with the following SQL statement:

SELECT * INTO tblEmpPhones
FROM qryEmpPhones
ORDER BY EmpNum, 3;

4.) Open the tblEmpPhones table and edit the field defaults (such as

size
of the text field), assign the primary key, open the table properties

and
change the Subdatasheet Name combo box to [None], then save the new

table.

5.) Open the Relationships window and create the relationship between

the
tblEmpPhones and tblPhoneTypes tables, then save the change to the
Relationships window.

I'd also suggest not using special keys, like # and spaces in field

names
and table names to avoid bugs later. You may even want to add an

additional
field to the tblEmpPhones table to indicate which phone number is the
primary phone number to reach the employee at.

HTH.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)


"Jonathan Brown" Jonathan wrote in

message
...
I didn't normalize my database as well as I wish I had. I have a

table
called EmpInfo that's built essentially as follows:

Emp#
HomePhone
CellPhone
BusinessPhone

What I would likek to do I build a different table called EmpPhones

that
would like like this:

Emp# (this field would be related to the Emp# field in table EmpInfo)
Phone#
Type (the type field would be a lookup to another table with a list of
different types of phone number)

The Emp# and Phone# fields together would make up my multiple field

primary
key.

How would I combine the the HomePhone, Cellphone, and BusinessPhone

into
one
column, and then have 2 other columns with it's associated Emp# and

Type?

Any suggestions would be greatly appreciated.







  #8  
Old December 12th, 2004, 07:39 AM
Jeff Conrad
external usenet poster
 
Posts: n/a
Default

Excuse me Gunny, but I assume I am on that short list, correct?
I bookmarked your site a long time ago!

--
Jeff Conrad
Access Junkie
Bend, Oregon

"'69 Camaro" AM wrote in message
...
Hi, Tina.

Glad you liked it! I'll tell the other consultants here, because that makes
three people who've bookmarked our site! (Just kidding. We're up to five
now. ;-) )

Have your ears been burning? Your name came up in a discussion here the
other day. (Don't worry. These were favorable remarks.) Where are you in
L.A.? The Valley?

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)


"tina" wrote in message
...
hey, Gunny, just checked out your website. very nice - it joined mvps.org,
lebans.com, granite.ab.ca, and all the other Access bookmarks in my

browser.
the article on marketing was especially interesting, and very entertaining
too! btw, we're neighbors, i'm in so cal also.


"'69 Camaro" AM wrote

in
message ...
Hi, Jonathan.

Any suggestions would be greatly appreciated.

You may want to look even further ahead in your organization's needs for
this database, such as how many other types of phone numbers are likely

to
be added. Pagers come to mind.

I suggest taking these five steps:

1.) Create a table for the types of phone numbers. Add an Autonumber
primary key and the "PhoneType" field to hold the name of the phone

type.
It might look like this:

Table: tblPhoneTypes

PTID PhoneType
1 Business
2 Cell
3 Home
4 Pager

2.) Create a query that gathers the information from the EmpInfo table

in
a
normalized structure and name this query qryEmpPhones:

SELECT EmpNum, HomePhone AS PhoneNum, 3 AS PTID
FROM EmpInfo
UNION
SELECT EmpNum, CellPhone, 2 AS PTID
FROM EmpInfo
UNION SELECT EmpNum, BusinessPhone, 1 AS PTID
FROM EmpInfo;

3.) Create a make table query with the following SQL statement:

SELECT * INTO tblEmpPhones
FROM qryEmpPhones
ORDER BY EmpNum, 3;

4.) Open the tblEmpPhones table and edit the field defaults (such as

size
of the text field), assign the primary key, open the table properties

and
change the Subdatasheet Name combo box to [None], then save the new

table.

5.) Open the Relationships window and create the relationship between

the
tblEmpPhones and tblPhoneTypes tables, then save the change to the
Relationships window.

I'd also suggest not using special keys, like # and spaces in field

names
and table names to avoid bugs later. You may even want to add an

additional
field to the tblEmpPhones table to indicate which phone number is the
primary phone number to reach the employee at.

HTH.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)


"Jonathan Brown" Jonathan wrote in

message
...
I didn't normalize my database as well as I wish I had. I have a

table
called EmpInfo that's built essentially as follows:

Emp#
HomePhone
CellPhone
BusinessPhone

What I would likek to do I build a different table called EmpPhones

that
would like like this:

Emp# (this field would be related to the Emp# field in table EmpInfo)
Phone#
Type (the type field would be a lookup to another table with a list of
different types of phone number)

The Emp# and Phone# fields together would make up my multiple field
primary
key.

How would I combine the the HomePhone, Cellphone, and BusinessPhone

into
one
column, and then have 2 other columns with it's associated Emp# and

Type?

Any suggestions would be greatly appreciated.



  #9  
Old December 12th, 2004, 11:03 AM
'69 Camaro
external usenet poster
 
Posts: n/a
Default

Hi, Jeff.

I bookmarked your site a long time ago!


Yup! Back in the middle of August, wasn't it?

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)


"Jeff Conrad" wrote in message
...
Excuse me Gunny, but I assume I am on that short list, correct?
I bookmarked your site a long time ago!

--
Jeff Conrad
Access Junkie
Bend, Oregon

"'69 Camaro" AM wrote

in message
...
Hi, Tina.

Glad you liked it! I'll tell the other consultants here, because that

makes
three people who've bookmarked our site! (Just kidding. We're up to

five
now. ;-) )

Have your ears been burning? Your name came up in a discussion here the
other day. (Don't worry. These were favorable remarks.) Where are you

in
L.A.? The Valley?

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)


"tina" wrote in message
...
hey, Gunny, just checked out your website. very nice - it joined

mvps.org,
lebans.com, granite.ab.ca, and all the other Access bookmarks in my

browser.
the article on marketing was especially interesting, and very

entertaining
too! btw, we're neighbors, i'm in so cal also.


"'69 Camaro" AM

wrote
in
message ...
Hi, Jonathan.

Any suggestions would be greatly appreciated.

You may want to look even further ahead in your organization's needs

for
this database, such as how many other types of phone numbers are

likely
to
be added. Pagers come to mind.

I suggest taking these five steps:

1.) Create a table for the types of phone numbers. Add an

Autonumber
primary key and the "PhoneType" field to hold the name of the phone

type.
It might look like this:

Table: tblPhoneTypes

PTID PhoneType
1 Business
2 Cell
3 Home
4 Pager

2.) Create a query that gathers the information from the EmpInfo

table
in
a
normalized structure and name this query qryEmpPhones:

SELECT EmpNum, HomePhone AS PhoneNum, 3 AS PTID
FROM EmpInfo
UNION
SELECT EmpNum, CellPhone, 2 AS PTID
FROM EmpInfo
UNION SELECT EmpNum, BusinessPhone, 1 AS PTID
FROM EmpInfo;

3.) Create a make table query with the following SQL statement:

SELECT * INTO tblEmpPhones
FROM qryEmpPhones
ORDER BY EmpNum, 3;

4.) Open the tblEmpPhones table and edit the field defaults (such

as
size
of the text field), assign the primary key, open the table

properties
and
change the Subdatasheet Name combo box to [None], then save the new

table.

5.) Open the Relationships window and create the relationship

between
the
tblEmpPhones and tblPhoneTypes tables, then save the change to the
Relationships window.

I'd also suggest not using special keys, like # and spaces in field

names
and table names to avoid bugs later. You may even want to add an
additional
field to the tblEmpPhones table to indicate which phone number is

the
primary phone number to reach the employee at.

HTH.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address, so that a

message
will be forwarded to me.)


"Jonathan Brown" Jonathan wrote in
message
...
I didn't normalize my database as well as I wish I had. I have a

table
called EmpInfo that's built essentially as follows:

Emp#
HomePhone
CellPhone
BusinessPhone

What I would likek to do I build a different table called

EmpPhones
that
would like like this:

Emp# (this field would be related to the Emp# field in table

EmpInfo)
Phone#
Type (the type field would be a lookup to another table with a

list of
different types of phone number)

The Emp# and Phone# fields together would make up my multiple

field
primary
key.

How would I combine the the HomePhone, Cellphone, and

BusinessPhone
into
one
column, and then have 2 other columns with it's associated Emp#

and
Type?

Any suggestions would be greatly appreciated.





  #10  
Old December 12th, 2004, 06:27 PM
Jeff Conrad
external usenet poster
 
Posts: n/a
Default

Yep, right around Aug 9th sometime.
;-)

It's been on my massive list of Access links (which I occasionally post in the NG) ever since then.

--
Jeff Conrad
Access Junkie
Bend, Oregon

"'69 Camaro" AM wrote in message
...
Hi, Jeff.

I bookmarked your site a long time ago!


Yup! Back in the middle of August, wasn't it?

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)


"Jeff Conrad" wrote in message
...
Excuse me Gunny, but I assume I am on that short list, correct?
I bookmarked your site a long time ago!

--
Jeff Conrad
Access Junkie
Bend, Oregon

"'69 Camaro" AM wrote

in message
...
Hi, Tina.

Glad you liked it! I'll tell the other consultants here, because that

makes
three people who've bookmarked our site! (Just kidding. We're up to

five
now. ;-) )

Have your ears been burning? Your name came up in a discussion here the
other day. (Don't worry. These were favorable remarks.) Where are you

in
L.A.? The Valley?

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)


"tina" wrote in message
...
hey, Gunny, just checked out your website. very nice - it joined

mvps.org,
lebans.com, granite.ab.ca, and all the other Access bookmarks in my
browser.
the article on marketing was especially interesting, and very

entertaining
too! btw, we're neighbors, i'm in so cal also.


"'69 Camaro" AM

wrote
in
message ...
Hi, Jonathan.

Any suggestions would be greatly appreciated.

You may want to look even further ahead in your organization's needs

for
this database, such as how many other types of phone numbers are

likely
to
be added. Pagers come to mind.

I suggest taking these five steps:

1.) Create a table for the types of phone numbers. Add an

Autonumber
primary key and the "PhoneType" field to hold the name of the phone
type.
It might look like this:

Table: tblPhoneTypes

PTID PhoneType
1 Business
2 Cell
3 Home
4 Pager

2.) Create a query that gathers the information from the EmpInfo

table
in
a
normalized structure and name this query qryEmpPhones:

SELECT EmpNum, HomePhone AS PhoneNum, 3 AS PTID
FROM EmpInfo
UNION
SELECT EmpNum, CellPhone, 2 AS PTID
FROM EmpInfo
UNION SELECT EmpNum, BusinessPhone, 1 AS PTID
FROM EmpInfo;

3.) Create a make table query with the following SQL statement:

SELECT * INTO tblEmpPhones
FROM qryEmpPhones
ORDER BY EmpNum, 3;

4.) Open the tblEmpPhones table and edit the field defaults (such

as
size
of the text field), assign the primary key, open the table

properties
and
change the Subdatasheet Name combo box to [None], then save the new
table.

5.) Open the Relationships window and create the relationship

between
the
tblEmpPhones and tblPhoneTypes tables, then save the change to the
Relationships window.

I'd also suggest not using special keys, like # and spaces in field
names
and table names to avoid bugs later. You may even want to add an
additional
field to the tblEmpPhones table to indicate which phone number is

the
primary phone number to reach the employee at.

HTH.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address, so that a

message
will be forwarded to me.)


"Jonathan Brown" Jonathan wrote in
message
...
I didn't normalize my database as well as I wish I had. I have a
table
called EmpInfo that's built essentially as follows:

Emp#
HomePhone
CellPhone
BusinessPhone

What I would likek to do I build a different table called

EmpPhones
that
would like like this:

Emp# (this field would be related to the Emp# field in table

EmpInfo)
Phone#
Type (the type field would be a lookup to another table with a

list of
different types of phone number)

The Emp# and Phone# fields together would make up my multiple

field
primary
key.

How would I combine the the HomePhone, Cellphone, and

BusinessPhone
into
one
column, and then have 2 other columns with it's associated Emp#

and
Type?

Any suggestions would be greatly appreciated.



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Duplicate data Rob Green Database Design 3 November 7th, 2004 03:08 AM
Access & OleDb - generating schema changes, problem with identity/counter fields. Thomas Tomiczek [MVP] Database Design 9 November 5th, 2004 10:32 AM
Autonumber Ally H. General Discussion 7 August 27th, 2004 04:51 PM
Semicolon delimited text query help Al Guerra Running & Setting Up Queries 3 August 12th, 2004 11:50 AM
Name not showing ID is René Setting Up & Running Reports 11 June 29th, 2004 01:40 AM


All times are GMT +1. The time now is 02:49 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.