Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

MSSql -> normaln thing or a bug

c# mssql

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1 Tonchi

Tonchi

    Helping the world with programming

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1249 posts

Posted 03 July 2013 - 04:42 PM

Hi guys,

 

I have been doing some easy project for my friend in C#. I was working with mdf database (default database in Visual Studio). When I wanted to add a new table, I was unable to do it and it take me a few hours to find on the internet that I have to use some other datatype than 'text' for primary key in order to create a table. I was shocked since I never heard that you have to watch out which datatype you choose for your primary key.

 

Is this thing normal or I should consider it as a bug?


Microsoft Student Partner, Microsoft Certified Professional


#2 Luthfi

Luthfi

    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1320 posts

Posted 03 July 2013 - 06:16 PM

If you understand what is text data type, then you will find that it is logical to not use it for primary key (or any kind of index if that matter). It is actually a type of BLOB field. With this type of field you don't get to specify field size, means that the actual size for its values might be between 0 and 231-1 (2,147,483,647) bytes .

 

I believe you can imagine the calculating power required when you need to build and work on indexes based on such field, to still get acceptable speed/throughput? That is still not considering the size required to store of index.

 

Edit:

So, it's normal. Not a bug.


Edited by Luthfi, 12 October 2013 - 04:55 AM.





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download