Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Avoid referring Column B to Column A and viz versa

Posted on 2007-11-14
6
Medium Priority
?
368 Views
Last Modified: 2011-10-03
I want to avoid corss referring Column B to Column A and viz versa. I have a Column ( B ) refering to Column (A).  The following cases are fine
Col A Col B
1          2
2          3
3

but the following cases are not fine
Col A Col B
1          1
2          3
3          2

Can i do this in by using any database constraint?
0
Comment
Question by:x1877
  • 3
  • 2
6 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 20279924
what about this:
Col A Col B
1          2
2          3
3          1

(ie the third row closing the "circuit" ?
0
 
LVL 14

Expert Comment

by:twoboats
ID: 20279992
To Angel's point - it's about travesing a network, to decide if it has rows. I did once write code (don't have it) that would deal with any number of levels in 2 passes. Couldn't do it in 1 pass (unless number of levels was known & fixed). Was a chunk of nightmarish code, so haven't kept it. Probably best achieved in a loop.
0
 
LVL 14

Expert Comment

by:twoboats
ID: 20279999
should read

decide if it has loops
0
Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

 

Author Comment

by:x1877
ID: 20280056
angelIII:
Sorry according to busines logic even thats not possible. In that way my example is not perfect.
I am trying to achive the following

Col A Col B
1          2
2          
3          4
4
5           4
Means only 1 parent and 1 child or 1 parent and many children. No grandchild
0
 
LVL 14

Accepted Solution

by:
twoboats earned 2000 total points
ID: 20280140
Don't think you can do it in a constraint, butr should be achievable in a trigger using self joins
0
 

Author Comment

by:x1877
ID: 20358627
trigger not tried...planning to do it using front end code.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Lotus Notes has been used since a very long time as an e-mail client and is very popular because of it's unmatched security. In this article we are going to learn about  RRV Bucket corruption and understand various methods to Fix "RRV Bucket Corrupt…
Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

963 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