Assuming we have the following table (that stores hierarchical data) :
CREATE TABLE [staff] (
[employee] [int] NOT NULL ,
[employee_name] [varchar] (10) NULL ,
[supervisor] [int] NULL ,
PRIMARY KEY CLUSTERED
) ON [PRIMARY] ,
) REFERENCES [staff] (
I ‘ll built a function that returns the no of children given the node id.
For most DBAs, normalization is an understood concept, a bread and butter bit of knowledge. However, it is not at all unusual to review a database design by a development group for an OLTP (OnLine Transaction Processing) environment and find that the schema chosen is anything but properly normalized. This article by Brian Kelley will give you the core knowledge to data model.