Friday, March 23, 2012

parent child relationship

I am using SQL 2000. I have a table with which has both the parent row and child rows.

Pid type status

- - --

1 P 0 -Parent row

2 C 0

3 C 1

4 C 0

I added a new column "Pstatus" to the table. I have to update the table to show the status of parent row against the child row in new col as below.... There are a million records with different parent/child.

Pid type status Pstatus(new col)

- - -- -

1 P 0 0 -Parent row

2 C 0 0

3 C 1 0

4 C 0 0

Thanks...........

How do you know which Parent the Child should be associated with?

It is not clear what you are attempting to accomplish. Please offer more explanition, and perhaps sample data (in the form of INSERT statements).

|||Hey.. What you want to do here? Give more Details?|||

I apologize for the mistake in providing the complete info....The Parent Child relation is defined by Pid..which i have now corrected as below. I hope this helps.....

Pid type status Pstatus(new col)

- - -- -

1 P 0 0 -Parent row

1 C 0 0

1 C 1 0

1 C 0 0

|||

I apologize for the mistake in providing the complete info....The Parent Child relation is defined by Pid..which i have now corrected as below. I hope this helps.....

Pid type status Pstatus(new col)

- - -- -

1 P 0 0 -Parent row

1 C 0 0

1 C 1 0

1 C 0 0

|||

IF PID refers to the Parent, is the record with PID=1 AND Type=P its' own parent? This design only allows for 2 levels.

So, there is no unique identifier for each Child?

Something important is missing here. It seems like there 'should' also an [ID] PRIMARY KEY column. A common design issue is to provide each row with a unique method of distinguishing that row from any other row, and in the case of hierachical designs, also a column to indicate which record is the parent. In this case, while you can create a suposition about parentage by using the [Type] column, you would not be able to tell row 2 from row 4 (using your data above)? Even identical twins have names -and different fingerprints, etc.

Otherwise, as I ask before, how do you determine

No comments:

Post a Comment