1

I want to store the view meta info like on which tables & columns & queries its created etc, into another mapping table,so that I can reproduce them later point of time.

Right now I have a structure like this -

CREATE TABLE [dbo].[MAPPING_VIEW]
(
    [ID] [int] NOT NULL,
    [OLD_VIEW] [varchar](40) NULL,
    [NEW_VIEW] [varchar](40) NULL,

    CONSTRAINT [PK_MAPPING_VIEW] PRIMARY KEY CLUSTERED 
    ([ID] ASC)
) 

CREATE TABLE [dbo].[MAPPING_VIEW_TBL]
(
    [ID] [int] NULL,
    [PARENT_ID] [int] NULL,
    [OLD_TBL] [varchar](40) NULL,
    [NEW_TBL] [varchar](40) NULL
) 

ALTER TABLE [dbo].[MAPPING_VIEW_TBL] WITH NOCHECK 
ADD CONSTRAINT [FK_MAPPING_VIEW_TBL_ID] 
FOREIGN KEY([PARENT_ID]) REFERENCES [dbo].[MAPPING_VIEW] ([ID])

CREATE TABLE [dbo].[MAPPING_VIEW_TBL_COL]
(
    [ID] [int] NULL,
    [PARENT_ID] [int] NULL,
    [VIEW_ID] [int] NULL,
    [OLD_COL] [varchar](40) NULL,
    [NEW_COL] [varchar](40) NULL,
    [OLD_ALIAS] [varchar](40) NULL,
    [NEW_ALIAS] [varchar](40) NULL
)

ALTER TABLE [dbo].[MAPPING_VIEW_TBL_COL] WITH NOCHECK 
ADD CONSTRAINT [FK_MAPPING_VIEW_TBL_COL_PARENT_ID] 
FOREIGN KEY([PARENT_ID]) REFERENCES [dbo].[MAPPING_TBL] ([ID])

ALTER TABLE [dbo].[MAPPING_VIEW_TBL_COL]  WITH NOCHECK 
ADD CONSTRAINT [FK_MAPPING_VIEW_TBL_COL_VIEW_ID] 
FOREIGN KEY([VIEW_ID]) REFERENCES [dbo].[MAPPING_VIEW] ([ID])

I know, which is not enough. Any suggestions would be appreciated

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
code-match
  • 21
  • 8

0 Answers0