Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
|
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 4th, 2007, 11:09 AM
Authorized User
 
Join Date: Jun 2006
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default Array or Table Performance comparison

Hello, I am thinking of creating a table with a field as such-

CompID:CompWebLink:True/False:DD/MM/YY:DD/MM/YY:True/False:0/60x200::

- short explanation of above array entries -
(CompID),(URL of Link),(URL still exists?),(Date last checked this DB),(Date link last worked), (is link on front page), (Banner link size)

Would i be better creating a new table for each CompID?

 
Old June 4th, 2007, 12:14 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 839
Thanks: 0
Thanked 1 Time in 1 Post
Default

Quote:
quote:Originally posted by bananas
Would i be better creating a new table for each CompID?
Absolutely.

You need to study up on database normalization. This is a set of rules concerning database table design which have been in existence since about 1972. A database is said to be normalized if it complies with these rules.

The very first rule essentially states that the data in a column be atomic, that is, comprised of simple, indivisible values. This form precludes multivalued attributes (groups) and composite data, such as the column you suggest.

Tables which violate first normal form can be very difficult to query against. For example, try to write a query against your proposed structure which lists all the links which worked last month...

Jeff Mason
Custom Apps, Inc.
je.mason@comcast.net
 
Old June 5th, 2007, 04:24 AM
Authorized User
 
Join Date: Jun 2006
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thankyou very much for your reply. I'm self taught on SQL and as such I've not had a basic understanding. You've pointed me in the right direction and now I feel I've got a grasp on at least one fundemental!

You made a good point on the difficulty of querying my column, thankyou for saving me wasting half a day creating a bad DB!

Mark

 
Old June 5th, 2007, 05:14 AM
Authorized User
 
Join Date: Jun 2006
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I've been looking at creating a Dynamic Table for each User:

SELECT @SQL = 'Create Table [dbo].' + @UserID + '('
SELECT @SQL = @SQL + '[UID] int IDENTITY (1, 1) PRIMARY KEY CLUSTERED, [ID] nvarchar(10),'
SELECT @SQL = @SQL + '[LinkExists] bit, [LastChecked] datetime, [LastWorked] datetime,'
SELECT @SQL = @SQL + '[FrontPage] bit, [BannerSize] nvarchar(20) )'

Exec (@SQL)

I don't think this is a good idea as all my queries would require Dynamic SQL to access a Database that matches a UserID. Also I've done a bit of reading on using Dynamic SQL with @TableName variable and it suggested better Database design is to use just one table and pull the rows with a query by a UserID column. Sounds like the best option all things considered.

 
Old June 5th, 2007, 05:29 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 839
Thanks: 0
Thanked 1 Time in 1 Post
Default

You are much, much better off with a single table rather than an entire constellation of them.

Once again, consider the difficulty of querying. Analysis across the set of users will be next to impossible ("How many users had links which worked last month?").

Jeff Mason
je.mason@comcast.net





Similar Threads
Thread Thread Starter Forum Replies Last Post
Table Look Up and Comparison mmcdonal Access VBA 1 November 17th, 2004 05:28 PM
Array to Array comparison pavel Pro VB 6 0 March 24th, 2004 06:33 PM
Table Performance mikericc Access 10 February 17th, 2004 02:39 PM
Table comparison damnnono_86 Access 7 October 29th, 2003 10:36 AM
Table performance rignhom SQL Server 2000 1 August 4th, 2003 06:23 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.