Solved

Avoid referring Column B to Column A and viz versa

Posted on 2007-11-14
6
354 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
[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
  • 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

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

Get Database Help Now w/ Support & Database Audit

Keeping your database environment tuned, optimized and high-performance is key to achieving business goals. If your database goes down, so does your business. Percona experts have a long history of helping enterprises ensure their databases are running smoothly.

Question has a verified solution.

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

These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

734 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