gladiator
gladiator

Reputation: 11

Hierarchical Table and Query in SQL Server

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            sdfs      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?

Upvotes: 1

Views: 831

Answers (1)

user194076
user194076

Reputation: 9017

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.

Upvotes: 1

Related Questions