[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Linked Tables

Posted on 2004-10-20
3
Medium Priority
?
164 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
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…
Starting up a Project

649 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