473,769 Members | 5,205 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Do I need INDEXes when a UNIQUE has been set?

Having re-jigged the UNIQUE to the proper syntax it does do what I want -
wahey!!

Just to finish this off here is my final table DDL:

CREATE TABLE `WEBSTRINGS` (
`STRINGID` INT NOT NULL AUTO_INCREMENT,
`TOKENID` INT DEFAULT 0,
`LANGID` VARCHAR(30),
`STRINGTEXT` VARCHAR(255),
`PAGEID` TINYINT UNSIGNED DEFAULT 0,
`GUI` TINYINT UNSIGNED DEFAULT 0,

INDEX `indxLANGID` (`LANGID`),
INDEX `indxGUI` (`GUI`),
INDEX `indxTOKENID` (`TOKENID`),
INDEX `indxSTRINGID` (`STRINGID`),
UNIQUE `unqSTRINGID` (`LANGID`,`STRI NGTEXT`,`GUI`),
PRIMARY KEY `PrimaryKey` (`STRINGID`)
);

Do I really need the other INDEXes if I have this UNIQUE one set (and a PK)
?

What would be the pluses and minuses of keeping the indexes?

Thanks

Laphan
Jul 20 '05 #1
2 1401

"Laphan" <ne**@DoNotEmai lMe.co.uk> skrev i en meddelelse
news:41******** **@127.0.0.1...
Having re-jigged the UNIQUE to the proper syntax it does do what I want -
wahey!!

Just to finish this off here is my final table DDL:

CREATE TABLE `WEBSTRINGS` (
`STRINGID` INT NOT NULL AUTO_INCREMENT,
`TOKENID` INT DEFAULT 0,
`LANGID` VARCHAR(30),
`STRINGTEXT` VARCHAR(255),
`PAGEID` TINYINT UNSIGNED DEFAULT 0,
`GUI` TINYINT UNSIGNED DEFAULT 0,

INDEX `indxLANGID` (`LANGID`),
INDEX `indxGUI` (`GUI`),
INDEX `indxTOKENID` (`TOKENID`),
INDEX `indxSTRINGID` (`STRINGID`),
UNIQUE `unqSTRINGID` (`LANGID`,`STRI NGTEXT`,`GUI`),
PRIMARY KEY `PrimaryKey` (`STRINGID`)
);

Do I really need the other INDEXes if I have this UNIQUE one set (and a PK)

PrimaryKey is a special case of UNIQUE which is a special case of INDEX

You can omit the indxLANGID as it is an "initial substring" of unqSTRNGID.
You can omit indxSTRNGID as it contains the same as the PrimaryKey index.
What would be the pluses and minuses of keeping the indexes?


I can only see the minuses of having duplicate data.

Leif
Jul 20 '05 #2

"Laphan" <ne**@DoNotEmai lMe.co.uk> skrev i en meddelelse
news:41******** **@127.0.0.1...
Having re-jigged the UNIQUE to the proper syntax it does do what I want -
wahey!!

Just to finish this off here is my final table DDL:

CREATE TABLE `WEBSTRINGS` (
`STRINGID` INT NOT NULL AUTO_INCREMENT,
`TOKENID` INT DEFAULT 0,
`LANGID` VARCHAR(30),
`STRINGTEXT` VARCHAR(255),
`PAGEID` TINYINT UNSIGNED DEFAULT 0,
`GUI` TINYINT UNSIGNED DEFAULT 0,

INDEX `indxLANGID` (`LANGID`),
INDEX `indxGUI` (`GUI`),
INDEX `indxTOKENID` (`TOKENID`),
INDEX `indxSTRINGID` (`STRINGID`),
UNIQUE `unqSTRINGID` (`LANGID`,`STRI NGTEXT`,`GUI`),
PRIMARY KEY `PrimaryKey` (`STRINGID`)
);

Do I really need the other INDEXes if I have this UNIQUE one set (and a PK)

PrimaryKey is a special case of UNIQUE which is a special case of INDEX

You can omit the indxLANGID as it is an "initial substring" of unqSTRNGID.
You can omit indxSTRNGID as it contains the same as the PrimaryKey index.
What would be the pluses and minuses of keeping the indexes?


I can only see the minuses of having duplicate data.

Leif
Jul 20 '05 #3

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

Similar topics

0
1140
by: Laphan | last post by:
Having re-jigged the UNIQUE to the proper syntax it does do what I want - wahey!! Just to finish this off here is my final table DDL: CREATE TABLE `WEBSTRINGS` ( `STRINGID` INT NOT NULL AUTO_INCREMENT, `TOKENID` INT DEFAULT 0, `LANGID` VARCHAR(30), `STRINGTEXT` VARCHAR(255),
3
1803
by: Jack A | last post by:
OK Guys. I'm fed up of the query below taking too much time. I CANT change the query since it is generated by a 3rd party product. I can change indexes and add new indexes though. The schema of the tables is given below. The most expensive operation is a bookmark lookup on VGNCCB_ROLE_JT. I created the speed_up_login index as a covering index to cover the query but that has not seemed to help. Any ideas, suggestions are most welcome...
7
1983
by: robertbrown1971 | last post by:
I just inherited a Java application with a fairly complex data model that does not yet have any indexes except those on primary keys. It is still in development and before I get to do any performance testing I want to put some default indexes on it. I realize that this a very vague request but it's better than nothing so I want to start with those that are generally a good idea and then tune those areas that require more fine grained...
3
1696
by: Randell D. | last post by:
Folks, My internet access is intermitent until I get my own connection inside the next ten days - I say this so that I can thank in advance who ever gives a few seconds to read/answer my query... Basically - I have three columns in my table... product name hash, product tax code and a unique numeric record id. A product can contain one or more taxes hence this table is a
2
1743
by: alex.mcshane | last post by:
Hi - I would be grateful for guidance regarding the following. (Please note that my DB2 backgorund is principally OS/390. I have only recently become involved in DB2 for LUW). OVERVIEW I have been using Scripted Files to Create Tables and an associated Primary Indexe via the DB2 Command Window.
2
1548
by: DJG | last post by:
I need some help with a TreeView control in VB.Net I've got a datatable with about 8000 rows. 500 are 'folders', and the other 7500 rows are 'jobs'. It's a logical representation of some data, and not a physical drive. Each row has: master_key (unique id) folder_name (name for the user to see) parent_key (the master_key of the parent folder)
3
20314
by: db2admin | last post by:
Hello, I always assumed that dropping table will drop everything associated with it like indexes, references etc. I just noticed that after dropping table A and recreating it and then creating index on it gave me error DROP TABLE tmp DB21034E The command was processed as an SQL statement because it was not a valid Command Line Processor command. During SQL processing it
1
1552
by: digitalox | last post by:
All efforts to rebuild indexes fails. Not with an error, but they still show high fragmentation. The environment: SQL Server 2005 in 2000 compatibility mode non-clustered indexes on tables that have clustered indexes with unique constraint Tried so far: Rebuild, reorganize, manual drop and recreate, setting the db in 2005 mode This only seems to happen on the tables that also have the clustered index with a unique contraint ( which...
16
4856
by: Okonita via DBMonster.com | last post by:
Hi all, I am comming along with all this Linus/DB2/scripting business...I am no longer scared of it!! (LOL). But, I need to create a .ksh script that does a REORGCHK and output only tables recommended for reorg. My goal is to reorgchk and run reorgs based on entries in this reorg file as shown in the example below. I have tried my hand at the following failing script and hope that gurus here can throw me a lifeline of examples on how to...
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...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3967
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.