dbTalk Databases Forums  

Logical proof of SQL change - HELP please!

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss Logical proof of SQL change - HELP please! in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Edward
 
Posts: n/a

Default Logical proof of SQL change - HELP please! - 07-27-2010 , 10:47 AM






See DDL below.

This represents a very simplistic view of my client's system, in which
there are actually about 95 tables and nearly 50 views. The views are
used primarily to provide a real-time snapshot of certain datasets for
auditing purposes. The database has medical applications so it has to
be carefully controlled.

Most of the views include in their JOIN a "nested view" - that is, a
view that contains common columns that are needed for all deriving
views (data items such as Patient Ref, Treatment Date etc.) I've
modelled this with the view CommonView below. The deriving views - an
example of which is given as SpecialView - includes CommonView in the
SELECT and other table or tables in the rest of the SQL joined as
shown.

It became necessary, for one (and only one) of the deriving views, to
expose a new column in the CommonView (see the final DDL at the
bottom) All that has happened is that an extra column (NewColumn3)
has been added to the set.

My client is concerned that the addition of this extra column to the
nested view could have an impact on the other views which derive from
this common view. Years ago, when I was studying discrete
mathematics at University, I believe that I could have formulated a
proof along the lines that the addition to a set does not affect any
intersection provided that the new addition does not appear in the
intersection, or something like that.

What I don't want to do is to allow my client to feel that they have
to retest all the deriving views, as that would be very undesirable in
terms of required effort. Can anyone think of a way of demonstrating
that what common sense tells me is irrefutable is logically provable?

Thanks

Edward

CREATE TABLE [Table_1](
[OldColumn1] [int] NOT NULL,
[OldColumn2] [nchar](10) NULL,
[NewColumn3] [nchar](10) NULL
) ON [PRIMARY]

CREATE TABLE [Table_2](
[C1] [int] NOT NULL,
[C2] [nchar](10) NULL,
[FKOldColumn1] [int] NULL
) ON [PRIMARY]

CREATE VIEW [CommonView]
AS
SELECT OldColumn1, OldColumn2
FROM dbo.Table_1

CREATE VIEW [SpecialView]
AS
SELECT dbo.CommonView.OldColumn1, dbo.CommonView.OldColumn2,
dbo.Table_2.C2
FROM dbo.CommonView INNER JOIN
dbo.Table_2 ON dbo.CommonView.OldColumn1 =
dbo.Table_2.FKOldColumn1


ALTER VIEW [dbo].[CommonView]
AS
SELECT OldColumn1, OldColumn2, NewColumn3
FROM dbo.Table_1

Reply With Quote
  #2  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: Logical proof of SQL change - HELP please! - 07-27-2010 , 04:39 PM






Edward (teddysnips (AT) hotmail (DOT) com) writes:
Quote:
My client is concerned that the addition of this extra column to the
nested view could have an impact on the other views which derive from
this common view.
Well, if any if the views include "SELECT *", they will be affected,
else they will not. Not at least in terms of logic. Performance could
be affected, though.





--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinf...ons/books.mspx

Reply With Quote
  #3  
Old   
Edward
 
Posts: n/a

Default Re: Logical proof of SQL change - HELP please! - 07-28-2010 , 04:05 AM



On 27 July, 22:39, Erland Sommarskog <esq... (AT) sommarskog (DOT) se> wrote:
Quote:
Edward (teddysn... (AT) hotmail (DOT) com) writes:
My client is concerned that the addition of this extra column to the
nested view could have an impact on the other views which derive from
this common view. *

Well, if any if the views include "SELECT *", they will be affected,
else they will not. Not at least in terms of logic. Performance could
be affected, though.
Thanks, Erland. Turns out that my client's in-house DBA was covering
his arse, and had raised the spectre of possible knock-on effects,
whereas he could easily have simply agreed with my assurance that the
change was minimal and had no further effects.

Edward

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.