dbTalk Databases Forums  

Very big table

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


Discuss Very big table in the comp.databases.ms-sqlserver forum.



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

Default Very big table - 04-16-2007 , 03:12 PM






Hi Expert,
In my DB i have a big table like this:

Primary key | param1 | para2 | param3 | param4 | ... | param100|
------------------+-----------+---------+-----------+------------+----
+--------------+
Quote:
| | |
| |
There is any way to build a parametric "Where" instead of manually
specification for example:

WHERE param1 = Y OR param2 = Y or param3 = Y ... param100 = Y

mybe for example:

WHERE paramx = Y

thanks



Reply With Quote
  #2  
Old   
DA Morgan
 
Posts: n/a

Default Re: Very big table - 04-16-2007 , 04:33 PM






Alex wrote:
Quote:
Hi Expert,
In my DB i have a big table like this:

Primary key | param1 | para2 | param3 | param4 | ... | param100|
------------------+-----------+---------+-----------+------------+----
+--------------+
| | | |
| | |

Then I would suggest you stop writing DML and fix the problem:

Primary Key | Parameter ID | Parameter Value

Your report writers, no doubt, will want to draw blood for such
an abominable lack of design.
--
Daniel A. Morgan
University of Washington
damorgan@x.washington.edu
(replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org


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

Default Re: Very big table - 04-16-2007 , 05:04 PM



Alex (ale.pam (AT) gmail (DOT) com) writes:
Quote:
Hi Expert,
In my DB i have a big table like this:

Primary key | param1 | para2 | param3 | param4 | ... | param100|
------------------+-----------+---------+-----------+------------+----
+--------------+
| | | |
| | |

There is any way to build a parametric "Where" instead of manually
specification for example:

WHERE param1 = Y OR param2 = Y or param3 = Y ... param100 = Y

mybe for example:

WHERE paramx = Y

It is not unlikely that the best design for the table would have been:


CREATE TABLE details (primarykey ....,
paramno tinyint NOT NULL,
value ....,
CONSTRAINT pk_deatils(primarykey, paramno))

In this case the query would be trivial to write.

With the current design, you could generate the code, but in the end
you would need that long chain of ORs one way or another.

Relational databases are simply not meant to be used that way.


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

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx


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.