Solved

Avoid referring Column B to Column A and viz versa

Posted on 2007-11-14
6
339 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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 

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 500 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

809 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