Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
dineshrajan_it
Posting Yak Master
217 Posts |
Posted - 2010-03-26 : 05:08:38
|
Hi, I have a Hierarchy table. It's like thisCREATE TABLE [dbo].[USHR_ProgressNotes]( [NotesId] [int] IDENTITY(1,1) NOT NULL, [NotesName] [varchar](200) NOT NULL, [ControlType] [varchar](100) NULL, [ParentNotesId] [int] NULL, [Depth] [tinyint] NULL, [Order] [tinyint] NULL, [Others] [varchar](8000) NULL, [ISCOMMON] [bit] NOT NULL, CONSTRAINT [PK__Progress__35AB5BAA1C880743] PRIMARY KEY CLUSTERED ( [NotesId] ASC)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]) ON [PRIMARY]Its a table that contain questions which contains its subsetquestion id as hierarchyNotesId NotesName ParentNotesId Order ISCOMMON1 Q1 Null 1 12 Q2 Null 2 13 Q3 Null 3 14 Q4 1 1 15 Q5 1 2 0So if i want all the questions of Q1. I will get Q4,Q5 based on mapping of its immediate parent in ParentNotesId.The table is fine. The prob is we have mapping to the questions with department. Each and every dept has one question set. A)So if i assign NotesId 1 to Dept "Dept1" then it will Q1(parent),Q4,Q5. B)The Prob is say i assign NotesId 1 to dept "Dept2" then it will also get Q1(parent),Q4,Q5. But say the "Dept2" maps to parentId but doesn't need its one of subset question say Q5 then output should be Q1(Parent), Q4 and not Q5.Help me. Thanks in Advance Iam a slow walker but i never walk back |
|
dineshrajan_it
Posting Yak Master
217 Posts |
Posted - 2010-03-26 : 05:23:25
|
I have set something like this by keeping secondary table that maps dept with the notes from parent tableCREATE TABLE MapDeptNotes( DeptNotesId INT IDENTITY(1,1) NOT NULL, OrgId INT NOT NULL, DeptId INT NOT NULL, NotesId INT )and also there is IsCommon field set in parent table for whether this question(Notes) is mandatory to all dept. in that case we can map only non mandatory(IsCommon=0) to that secondary table "MapDeptNotes"Is my approach correct. When iscommon is non mandatory i will check whether that question(notes) is mapped to dept in secondary table "MapDeptNotes"any help. PleaseIam a slow walker but i never walk back |
|
|
|
|
|
|
|