Wednesday, March 7, 2012

Metadata Inheritance

Hello,
I have written a mechanism which returns meta data back to a client for
different views. For example, one meta data item on a column is the Display
Name.
Now, so I don't have to keep attaching meta data to a particular column
every time I create a new view, I "inherit" the meta data from a parent view
or table by looking at all the same named columns in any views or tables
that the table depends (sysdepends) on.
The problem is, sometimes it make sense to change the name of a column in a
view from the underlying table (e.g. company table has a "name" column, but
in the view, you want to call it "company_name").
My question is, is there an easy way to determine where a view's column
really came from?
Thanks,
-PaulNever mind, I forgot to look at the depnumber column in sysdepends!
"Paul" <a@.b.com> wrote in message
news:eWN9knVCFHA.3940@.TK2MSFTNGP09.phx.gbl...
> Hello,
> I have written a mechanism which returns meta data back to a client for
> different views. For example, one meta data item on a column is the
> Display Name.
> Now, so I don't have to keep attaching meta data to a particular column
> every time I create a new view, I "inherit" the meta data from a parent
> view or table by looking at all the same named columns in any views or
> tables that the table depends (sysdepends) on.
> The problem is, sometimes it make sense to change the name of a column in
> a view from the underlying table (e.g. company table has a "name" column,
> but in the view, you want to call it "company_name").
> My question is, is there an easy way to determine where a view's column
> really came from?
> Thanks,
> -Paul
>|||Okay, now the hard question.
How do I correlate a column in the sysdepends table back to a column in the
resulting view's columns?
Thanks,
-Paul
"Paul" <a@.b.com> wrote in message
news:OBXyfyVCFHA.1836@.tk2msftngp13.phx.gbl...
> Never mind, I forgot to look at the depnumber column in sysdepends!
>
> "Paul" <a@.b.com> wrote in message
> news:eWN9knVCFHA.3940@.TK2MSFTNGP09.phx.gbl...
>|||On Wed, 2 Feb 2005 15:27:44 -0500, Paul wrote:

>Okay, now the hard question.
>How do I correlate a column in the sysdepends table back to a column in the
>resulting view's columns?
Hi Paul,
You don't.
You are probably thinking right now of fairly straight-forward views,
where such a mapping would be viable. But views can be fairly complex!
CREATE VIEW test
AS SELECT Col1 - Col2 AS A,
Col1 + Col2 AS B,
CASE WHEN EXISTS (SELECT *
FROM YZ
WHERE Foo = SomeTable.Bar)
THEN 1
ELSE 2
END AS C,
'Constant value' AS D,
Col3 + 1 AS E,
Col3 - 1 AS F
FROM SomeTable
How should each of the view's columns be correlated to each of the
underlying table's columns? And remember that this is also a fairly simple
example - I could come up with much more contrived views (some of my real
views for projects I do are much more contrived!)
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)

No comments:

Post a Comment