473,386 Members | 1,943 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,386 software developers and data experts.

update Address ID field in Person Table with Address Table

I'm new to this forum , and ms access too,

I have two tables :

address table(address ID, addressname, line 1 , line 2 , city , state country)
and
person table(person id , last name, firstname, addressID)

In order to link the two tables , i need to update the address id field in person table once the address table is updated with all the available addresses ? if yes , that should be done manually ! i have over 3000 records..

could someone suggest a detailed method of how this can be done in a much easier way.

thankyou for reading ,

Sreenu
Apr 1 '10 #1
3 2220
patjones
931 Expert 512MB
sreene -

The way things stand now, if you don't have any address ID's filled in the "person" table, you would in fact have to manually figure out which address belongs to which person and enter the appropriate address ID in that person's record. Very time consuming.

If you have a single table somewhere with the person and address combined, the best thing to do would be to assign an address ID to each person in that table however you see fit (it makes the most sense to use something derived from real life, such as customer number or something like that). Then you could split the table into a person and address table, retaining the address ID in each one.

I hope this makes sense.

Pat
Apr 2 '10 #2
Pat,

thankyou so much ,

can this be done using triggers in sql ?

s
Apr 2 '10 #3
patjones
931 Expert 512MB
sreene -

My knowledge of SQL is not advanced enough to advise you on the use of triggers. Here's what you can do though.

Suppose you have tblMain, with the combined information for "person" and "address":

tblMain (person id , last name, first name, address id, address name, line 1, line 2, city, state, country)

Using SQL in Access Query Design view, you can create the "person" table using:

Expand|Select|Wrap|Line Numbers
  1. SELECT tblMain.[person id], tblMain.[last name], tblMain.[first name], tblMain.[address id] 
  2. INTO tblPersons
  3. FROM tblMain
  4.  

This will create a new table and put the data in it. You might need to then open the table in design view to fine tune the column parameters, set keys, and so forth. You could do the same procedure to generate the address table:

Expand|Select|Wrap|Line Numbers
  1. SELECT tblMain.[address id], tblMain.[address name], tblMain.[line 1], tblMain.[line 2], tblMain.[city], tblMain.[state], tblMain.[country] 
  2. INTO tblAddresses
  3. FROM tblMain
  4.  

I personally think the ID structure you are using could be setup a little differently; the way it is now, you will either have a one-to-one relationship between a person and their address, or worse be storing a person more than once in the person table, with a different address ID each time, should you want to store more than one address for a person. By modifying the key structure a bit you can increase the flexibility of the database and maintain a normalized table structure.

Pat
Apr 3 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: David Berman | last post by:
I'm having a problem with an update operation in a stored procedure. It runs so slowly that it is unusable, unless I comment a part out in which case it is very fast. However, I need the whole...
2
by: (Pete Cresswell) | last post by:
For better or worse, I have chosen to implement mailing addresses in a particular application as a separate table. One Person ==> Many Addresses. It is a database for managing school reunions...
8
by: Maxi | last post by:
There is a lotto system which picks 21 numbers every day out of 80 numbers. I have a table (name:Lotto) with 22 fields (name:Date,P1,P2....P21) Here is the structure and sample data: ...
4
by: Ian Davies | last post by:
Hello I have seen some tutorials to put a update a counter field in a record. I have the counter field in a table that also has a field for a path to file. I display the records in a table on...
11
by: John | last post by:
Hi I had a working vs 2003 application with access backend. I added a couple fields in a table in access db and then to allow user to have access to these fields via app I did the following; ...
2
by: Miro | last post by:
I will ask the question first then fumble thru trying to explain myself so i dont waste too much of your time. Question / Statement - Every mdb table needs a PrimaryKey ( or maybe an index - i...
3
by: aaronvb | last post by:
Hi there, I'm currently trying to fix up a database that has had many different people work on it and therefore is confusing me no end. Currently i am trying to update a field, in the table ...
1
by: Arved Sandstrom | last post by:
This seems to be something so simple that none of the hundred-odd tutorials and forum threads that I have looked at (:-)) apparently thinks it's a problem. In a nutshell, I have two...
4
by: hapnendad | last post by:
In the question statement below Field names are in and variables are in (). All fields referenced are in what I have named the ‘PAR’ Table. Using MS Access 2003, I am working on a project...
4
by: justice750 | last post by:
Hi All, I am using a FormView control. The allows me to update records in the database. However, when a database field is null I can not update the field on the form. It works fine when the field...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.