Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 369
  • Last Modified:

Avoid referring Column B to Column A and viz versa

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
x1877
Asked:
x1877
  • 3
  • 2
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
what about this:
Col A Col B
1          2
2          3
3          1

(ie the third row closing the "circuit" ?
0
 
twoboatsCommented:
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
 
twoboatsCommented:
should read

decide if it has loops
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
x1877Author Commented:
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
 
twoboatsCommented:
Don't think you can do it in a constraint, butr should be achievable in a trigger using self joins
0
 
x1877Author Commented:
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.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now