473,769 Members | 6,337 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

unique keys

Hello,

I plan to create a table with 3 unique keys.

Combination of three fields has to be unique for each row in a table that
are vendor ID (char 8), vendor name (char 40), and vendor office (5).

Will it be okay to have a unique key which has a long character such as
vendor name?

How should I index those three fields? Those fields will be searched many
times.

RCW
Jul 20 '05 #1
2 2622
You would need to have three seperate non-unique indexes for id, name
and office respectively. (in your posting you say that these are
unique - this sounds strange given your later statement)

You should add a unique index that is a composite of the above.

Index names that long are no problem (assuming of course that you dont
have millions of rows).

Some additionals notes:

(1) If this database table contains vendors, I would have expected
that vendor id would be the unique primary key??? If it cannot be
unique, I would consider adding another column that is the unique
primary key (if you have not already done so).

(2) Consider making vendor name a varchar(40) rather than a char(40)

(3) You will need to investigate the types of queries that users make.
This may result in additional indexes (or removing some of the above)
"reneeccwes t" <re*********@ho tmail.com> wrote in message news:<xdkYa.932 3$ug.144@lakere ad01>...
Hello,

I plan to create a table with 3 unique keys.

Combination of three fields has to be unique for each row in a table that
are vendor ID (char 8), vendor name (char 40), and vendor office (5).

Will it be okay to have a unique key which has a long character such as
vendor name?

How should I index those three fields? Those fields will be searched many
times.

RCW

Jul 20 '05 #2
reneeccwest (re*********@ho tmail.com) writes:
I plan to create a table with 3 unique keys.

Combination of three fields has to be unique for each row in a table that
are vendor ID (char 8), vendor name (char 40), and vendor office (5).


It sounds funny to me that the vendor ID alone would not be unique.
OK, I can envision that a vendor has several offices, but several
names?

And if a vendor can have several offices, you should probably have the
offices in a subtable.

And as "Mystery Man" said, make that vendor name varchar(40).
--
Erland Sommarskog, SQL Server MVP, so****@algonet. se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #3

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

Similar topics

9
3738
by: MrBoom | last post by:
Does using uniqid seem a reasonable way of generating a unique row identifyer in a db table? It's *highly* unlikely that two ids are going to be generated in the same microsecond, but if they are, setting lcg as true should eliminate any problems I'd have thought. Anyway, these are my thoughts, do people agree?
2
2303
by: kevin parks | last post by:
hi. I've been banging my head against this one a while and have asked around, and i am throwing this one out there in the hopes that some one can shed some light on what has turned out to be a tough problem for me (though i am getting closer). i have been mucking with a lot of data in a dictionary that looks like:
5
2045
by: Roy Smith | last post by:
I've got a silly little problem that I'm solving in C++, but I got to thinking about how much easier it would be in Python. Here's the problem: You've got a list of words (actually, they're found by searching a data structure on the fly, but for now let's assume you've got them as a list). You need to create a comma-delimited list of these words. There might be duplicates in the original list, which you want to eliminate in the final...
2
5530
by: Tommo | last post by:
Hello All, I have a slight problem that goes like this. I have created a Perl hash where the keys are made up of numeric values, I was then sorting the 'keys' for this hash on their value (a<=>b etc), all was well until I got 2 keys with the same value, I seem to loose one of the hash entries. Is there a way around this problem .. cheers, Mark ..
9
2432
by: Rolf Kemper | last post by:
Dear Experts, I got stuck with the following problem and need your help. What I wnat to do is to get a set of distinct nodes. Before the distinct I have selected the multiple occourences already sucsessfully. However , the rest does not work as expected. Hope someone can help on that. Rolf
4
1578
by: Saso Zagoranski | last post by:
Hi, I'm making a simple application which will store different items (in a SQL server 2000 - MSDE database). Each item has a unique ID in this form: / / / an example: AZ12345/1234/1/A
11
7807
by: garyhoran | last post by:
Hi Guys, I have a collection that contains various attributes (stuff like strings, DateTime and Timespan) . I would like to access the collection in various orders at different points in the application ie sometimes I want to cycle through the values in the collection in DateTime order while at other times in TimeSpan order. Ideally I would like multiple keys - such as Timespan within DateTime order but maybe that is asking too much.
0
1383
by: Gabriel Genellina | last post by:
En Fri, 18 Apr 2008 12:23:08 -0300, Shawn Milochik <Shawn@Milochik.comescribió: A dictionary with keys is perfectly reasonable. But a *list* of values has to be searched linearly for every value: a O(n) process. As your friend suggested, searching a dictionary requires O(1) time. A set is even better in this case, because you don't have any use for the values in the inner dictionary (sets and dictionaries are very similar in the...
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10222
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10050
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9866
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8876
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7413
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5310
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...

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.