Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB 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 January 22nd, 2012, 04:05 AM
Friend of Wrox
 
Join Date: Oct 2009
Posts: 341
Thanks: 14
Thanked 3 Times in 3 Posts
Smile Choosing appropriate data type

Hello Imar,

Although you have chosen int data type for all type of records, e.g. for Genre Id, you have chosen int data type. Which is not necessary for Genre record.

It makes the application development faster, but I still want to know that
Is it fine to choose int for any record?
Doesn't it take a little more processing time than tinyint, smallint?
Won't it waste database space unnecessarily?

Many thanks....
 
Old January 22nd, 2012, 05:38 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

I prefer consistency over the optimal data type. That is, using ints everywhere makes your code a little easier to use. I doubt you'll be able to measure the performance difference between an int and a tinyint in an ASP.NET application.

But choose what works best for you; smaller datatypes indeed work for for tables like Genre.

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old January 22nd, 2012, 06:09 AM
Friend of Wrox
 
Join Date: Oct 2009
Posts: 341
Thanks: 14
Thanked 3 Times in 3 Posts
Smile

Quote:
I prefer consistency
I too prefer and it is really headache to remember different data types all the time.

But what about space that the larger data type will take...
 
Old January 22nd, 2012, 06:17 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Again, that would typically not be an issue in most ASP.NET applications. An int versus the other types is 4 bytes versus 2 or 1. You do the math to calculate when that becomes a problem:

http://msdn.microsoft.com/en-us/libr...v=sql.80).aspx
http://www.amazon.com/Western-Digita...227379&sr=1-12

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old January 22nd, 2012, 06:42 AM
Friend of Wrox
 
Join Date: Oct 2009
Posts: 341
Thanks: 14
Thanked 3 Times in 3 Posts
Smile

Thanks,

prior asking here I had asked the same here but they said for your data base life you should go for smallest data type.
(first 2 replies)

I was little confused so I ask here as I broadly follow your steps.

Why link to amazon???
 
Old January 22nd, 2012, 06:47 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

>> but they said for your data base life you should go for smallest data type.

Yes, that's what you typically do, but as I said earlier, I prefer consistency over the smallest data type when size is not that relevant.

The link to Amazon is to show how cheap large hard drives are. Unless you're storing billions of records, the int versus tinyint is not, IMO, a relevant discussion on storage....

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old January 22nd, 2012, 06:57 AM
Friend of Wrox
 
Join Date: Oct 2009
Posts: 341
Thanks: 14
Thanked 3 Times in 3 Posts
Smile

Ok fine, I will go to int.

Quote:
The link to Amazon is to show how cheap large hard drives are. Unless you're storing billions of records, the int versus tinyint is not, IMO, a relevant discussion on storage....
feel good to know that you too kid.

Thanks a lot





Similar Threads
Thread Thread Starter Forum Replies Last Post
he conversion of a char data type to a datetime data type resulted in an out-of-range adamhw Classic ASP Basics 3 December 23rd, 2009 07:18 AM
I need help choosing the right book. lJohnl BOOK: Beginning JavaScript 3rd Ed. ISBN: 978-0-470-05151-1 2 September 6th, 2007 08:03 AM
choosing directories joconnor PHP How-To 0 August 11th, 2004 09:12 AM
Choosing a database rbmese Visual C++ 3 August 9th, 2004 08:19 AM
Data Type error but it is the correct type Mitch SQL Server 2000 2 March 19th, 2004 11:31 AM





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