开发者

Hierarchical Table and Query in SQL Server

开发者 https://www.devze.com 2023-03-29 01:25 出处:网络
I have a scenario as follows: ManufacturerIDName 1XXX 2YYY DeptIDNameManufacturerID 1abc1 2bcd1 3efg2 ProductIDnamedeptid

I have a scenario as follows:

ManufacturerID        Name
1                     XXX
2                     YYY

DeptID     Name  ManufacturerID
1          abc   1
2          bcd   1
3          efg   2

ProductID   name      deptid
1           dfdfg     1
2           dfdg      2
3           sdfsd     2

PartsID      name      productid
1            sdf开发者_JAVA百科s      1
2            sfdfs     2
3            sdd       1

I want the above table structure to be made as hierarchical using levels. How do I design the table?


I cannot understand what hierarchy you need to make, but if you're using sql server 2008 please take a look at hierachyId datatype. And please provide more desdcription about you process. Now it looks straightforward:

Manufacturer has many departments, department has many products, product has many parts.

0

精彩评论

暂无评论...
验证码 换一张
取 消