473,394 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Two int fields or one varchar field

I am setting up a database that will receive a lot of data from two
separate telephone centers, the log table will in a short time have
over 1 million lines, and I was wondering if I should use 1 identify
field or two:

case 1:
[Id] [int] IDENTITY (1, 1) NOT NULL
[ServerId] [int] NOT NULL

case 2:
[Id] [varchar(20)] IDENTITY NOT NULL

Where in case 1 I would just use a combination of Id and ServerId to
identify the line, where in case 2 I would have the Id field a varchar
that would look something like A-000001, A-000002 for server 1 and
B-000001, B-000002 for server 2

Which solution will be faster when searching for a record when the
will have over 1 million lines?
Jul 20 '05 #1
3 2273
This is possibly the wrong question to ask. In both cases your number
appears to be just an arbitrary, internally generated code, so why would you
actually *want* to search on it if it doesn't contain any useful
information?

In general, if the cardinality of the column is the same in both cases it
should be faster to search on a NUMERIC or INTEGER than a VARCHAR of a
similar size.

--
David Portas
------------
Please reply only to the newsgroup
--
Jul 20 '05 #2
Re-reading your question, I think you really wanted to know about searching
on the server column. I suggest you put the server id in its own column.
This is good DB design and is easier than trying to parse it out from the
number.

--
David Portas
------------
Please reply only to the newsgroup
--
Jul 20 '05 #3

"David Portas" <RE****************************@acm.org> wrote in message
news:Aa********************@giganews.com...
This is possibly the wrong question to ask. In both cases your number
appears to be just an arbitrary, internally generated code, so why would you actually *want* to search on it if it doesn't contain any useful
information?

In general, if the cardinality of the column is the same in both cases it
should be faster to search on a NUMERIC or INTEGER than a VARCHAR of a
similar size.

I'll also point out that 1 million rows isn't that large of a DB for SQL
Server anyway and sorting should be fairly quick in either case.

--
David Portas
------------
Please reply only to the newsgroup
--

Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: James | last post by:
I am currently working on a PHP based website that needs to be able to draw from Oracle, MS SQL Server, MySQL and given time and demand other RDBMS. I took a lot of time and care creating a...
2
by: shivprasad koirala | last post by:
hi all(happy raksha bandhan day) we have one of Automation software for sales running for a customer.He was cool for the first month of product, but later popped with adding some extra...
1
by: steven virnig | last post by:
I know there has to be a way to do this, but I've gone brain dead. The scenario..a varchar field in a table contains a date range (i.e. June 1, 2004 - June 15, 2004 or September 1, 2004 -...
7
by: Clifford Heath | last post by:
I have a case where a table has two candidate primary keys, but either (but not both) may be NULL. I don't want to store a copy of the concatenated ISNULL'ed fields as an additional column, though...
22
by: jdokos | last post by:
Hello, I have a question about VARCHAR fields. Our application groups here are starting to use VARCHARs much more frequently. Even VARCHAR (2) to (9) length fields. They say this is because...
3
by: JIM.H. | last post by:
Hello, I am suing SELECT * from MyTable in a stored procedure and populate dropdown list. By using followings: ddlSP.DataSource = DS; ddlSP.DataTextField = "PName"; ddlSP.DataValueField = "PID";...
4
by: Sally Sally | last post by:
Hi all, I am wandering about the pros and cons of creating a separate serial field for a primary key when I already have a single unique field. This existing unique field will have to be a...
3
by: dchristjohn | last post by:
I am currently developing a small windows application using Visual Basic via Visual Studio 2005. My database resides on a SQL 2000 server. I have a table with three fields: id (int, Not Null)...
1
Shashi Sadasivan
by: Shashi Sadasivan | last post by:
Hi, Due to a certain circumstance i have to add a field to my table, which would be a varchar type. this varchar contructs istfel using 4 fields of type bit so if the table def goes as isA(bit),...
2
by: steph | last post by:
I have a table with 250 fields. Of course you are wondering why 250 fields... what could I possibly be storing in so many fields? I am using this table as a general import table for files that...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.