Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Database > SQL Language
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 4th, 2007, 11:09 AM
Authorized User
 
Join Date: Jun 2006
Location: , , .
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?

Reply With Quote
  #2 (permalink)  
Old June 4th, 2007, 12:14 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Hudson, MA, USA.
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
Reply With Quote
  #3 (permalink)  
Old June 5th, 2007, 04:24 AM
Authorized User
 
Join Date: Jun 2006
Location: , , .
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

Reply With Quote
  #4 (permalink)  
Old June 5th, 2007, 05:14 AM
Authorized User
 
Join Date: Jun 2006
Location: , , .
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.

Reply With Quote
  #5 (permalink)  
Old June 5th, 2007, 05:29 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Hudson, MA, USA.
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 11:25 PM.


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