This topic has been archived. It cannot be replied.
-
工作学习 / IT技术讨论 / 大侠有没有深入浅出地解释一下的文章:一个table里面的一个column是自己本身这个table的foreign key。即:同一个table里面的不同的column reference to同样的table。这样做有什么好处或者难言之隐?谢谢!
-mycar(豪情煮水);
2004-9-20
(#1895197@0)
-
这是一种建立TREE (Hierarchy) 的方法,你如果用ORACLE,可能发现‘LEVEL’被用在一些SELECT语句中
-handd(大熊猫®);
2004-9-21
(#1896001@0)
-
谢谢handd。能否举个具体的例子?谢谢!
-mycar(豪情煮水);
2004-9-21
(#1896119@0)
-
SampleRowNum, ParentRowNum, OtherColum
1,null,a
2,1,b
3,2,c
4,1,d
5,null,e
3 I
2 \ / 4
1 | 5 |
-handd(大熊猫®);
2004-9-21
{124}
(#1896144@0)
-
again3 I
2 \\ / 4
1 | 5 |
-handd(大熊猫®);
2004-9-21
{28}
(#1896152@0)
-
again2RowNum(PK), ParentRowNum(FK), OtherColum
1,null,a
2,1,b
3,2,c
4,1,d
5,null,e
-handd(大熊猫®);
2004-9-21
{81}
(#1896165@0)
-
thanks again 大熊猫®)! 能不能说说这种结构解决的是什么问题?比如现实生活中哪一种情形用这种结构比较好?谢谢!
-mycar(豪情煮水);
2004-9-21
(#1896635@0)
-
A customer hierarchy比如一下的CUSTOMER HIERARCHY:
1, Retail
2, Top2
3, Wal-Mart
4, Wal-Mart
5, Sam's Club
6, Loblaws
7, WholeSale
8, Cosco
The context of the table will be:
CustomerNumber(PK), ParentCustomerNumber(FK), CustomerName
1,null,Retail
2,1,Top2
3,2,Wal-Mart
4,3,Wal-Mart
5,3,Sam's Club
6,2,Loblaws
7,null,WholeSale
8,7,Cosco
-handd(大熊猫®);
2004-9-21
{403}
(#1896659@0)
-
The space cannot be shown correctly in the previous one比如一下的CUSTOMER HIERARCHY:
1, Retail
2, __Top2
3, ____Wal-Mart
4, ______Wal-Mart
5, ______Sam's Club
6, ____Loblaws
7, WholeSale
8, __Cosco
The context of the table will be:
CustomerNumber(PK), ParentCustomerNumber(FK), CustomerName
1,null,Retail
2,1,Top2
3,2,Wal-Mart
4,3,Wal-Mart
5,3,Sam's Club
6,2,Loblaws
7,null,WholeSale
8,7,Cosco
-handd(大熊猫®);
2004-9-21
{361}
(#1896663@0)
-
喔,有点儿似懂非懂了。。。是关系 和 层次 之间的关系。。。谢谢大侠!
-mycar(豪情煮水);
2004-9-21
(#1896687@0)
-
BOM: Bill of Materials
-yehongwei(天拖南);
2004-9-21
(#1896697@0)
-
Is this an example for you? In employee table, there is a column ReportsTo, it is an employee's boss's ID. This column reference to employee id column in the same table. Hope this helps.
-smallguy(oops);
2004-9-22
(#1898588@0)
-
This helps! Many thanks!
-mycar(豪情煮水);
2004-9-22
(#1898612@0)
-
Is this an example for you? In employee table, there is a column Boss's ID which is ID of employee's boss. It references to employee ID in the same table. Hope this helps.
-smallguy(oops);
2004-9-22
(#1898592@0)
-
Helpful! Thanks! I would build such model before: one employee table holding BossID which refers to Boss Table. Boss table has two columns: BossID and employeeID(ref. to employee).
-mycar(豪情煮水);
2004-9-22
(#1898622@0)
-
It is a typical sample to explain self reference used in database class
-smallguy(oops);
2004-9-23
(#1899025@0)