?
Solved

Linked Tables

Posted on 2004-10-20
3
Medium Priority
?
163 Views
Last Modified: 2010-04-17
I am after some advice, I am developing an application which contains quite a few link tables. Here is an exmaple of such a link.

A user can be a member of multiple branches.

Thefore I have a User, Branch and UserBranch table

I have Info Classes which represent the entities such as User and Branch. Each data class returns its own set of Info entities. (Such as UsersDB class  - Method GetUsers - Returns All Users in an array of User Info's) Say I am putting on a new user, the operator can add multiple branches to a list box. I then save these by way of the users db class (is this the best way, for exmaple pass along an array of branches). However if the record has already been previously saved is it better to remove the existing entries from the link table before adding new ones.
0
Comment
Question by:rocky050371
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 21

Accepted Solution

by:
MogalManic earned 2000 total points
ID: 12356645
I am unclear on what the question is?

Is the question:What is the best way to Update the list of branches assigned to a user?

If so:
The Delete/ReInsert method is the easiest way to implement this.  The disadvanatages are as follows:
  - Transaction may take longer(If user has 5 branches and you change 1, then 5 rows will be deleted and 5 rows will be inserted)
  - For each insert new keys will be generated.  If there are any foriegn key relationships between old data then it will be lost.

Another method is to keep a before branch list.  The user modifies the current branchlist.  The transcation code does a diff between the before branch list and the user modified branch list and builds insert/update/delete transactions.  (If the user has 5 branches and you change 1 then there will be 1 delete and 1 insert)

Another method is to use back pointers.  In other words, you already have a link in code from Users to branch.  Create a link in you class from branch to user.  To Delete a branch, null out the branch2user pointer.  Inserted branches would have null primary keys.  The transaction code would build the insert/update/delete transaction by iterating through the branch list.
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn different types of Android Layout and some basics of an Android App.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question