Do I need INDEXes when a UNIQUE has been set?

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default 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`,`STRINGTEXT`,`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 in realtion to
    my ASP page work?

    Thanks

    Laphan




    Laphan Guest

  2. Similar Questions and Discussions

    1. Unique Form inserting into many tables using unique id
      I have a Registration Form that have 3 steps. The data could be inserted into many (4) tables. Some data corresponding to a one table (the main or...
    2. indexes in cs
      Is it possible to easily create an InDesign index from a Word document? In other words, if the Word doc comes through with a special character...
    3. using indexes
      quick question regarding proper use of indexes. there are options for asc/desc sorting for each column when creating the index - for optimal...
    4. Indexes
      hello, here is my question. if you have a table called related_to and it has these fields: id active from_class_id from_id type_cid...
    5. Two indexes?
      I'm doing a book with a long contributor index as well as a standard index. Is it possible to use ID's indexing feature for both, or am I limited to...
  3. #2

    Default Re: Do I need INDEXes when a UNIQUE has been set?

    > Do I really need the other INDEXes if I have this UNIQUE one set (and a
    > PK)
    > ?
    That really depends on your goal, and how your database implements a UNIQUE
    constraint on a column.

    In SQL Server, this would be redundant, since a unique constraint is
    implemented as an index.

    However, since you use the word AUTO_INCREMENT, I don't think this is SQL
    Server at all. Have you considered asking in a forum dedicated to your
    database platform?
    > What would be the pluses and minuses of keeping the indexes in realtion to
    > my ASP page work?
    In general, indexes:

    - speed up sorting, bookmark lookups, and joins
    - slow down inserts

    With uniques in particular, they help to keep redundant data out of your
    database.

    So, as I said before, the "pluses and minuses" really depend on your
    objective(s).

    --
    [url]http://www.aspfaq.com/[/url]
    (Reverse address to reply.)


    Aaron [SQL Server MVP] Guest

  4. #3

    Default Re: Do I need INDEXes when a UNIQUE has been set?

    Hi Aaron

    Thanks for coming back to me.

    What I'm trying to understand is that isn't the unique already doing the job
    of the index, so do I really need to create a separate index as well for
    each of the fields/columns?

    Rgds Robbie

    "Aaron [SQL Server MVP]" <ten.xoc@dnartreb.noraa> wrote in message
    news:OFNTSg4cEHA.1048@tk2msftngp13.phx.gbl...
    > Do I really need the other INDEXes if I have this UNIQUE one set (and a
    > PK)
    > ?
    That really depends on your goal, and how your database implements a UNIQUE
    constraint on a column.

    In SQL Server, this would be redundant, since a unique constraint is
    implemented as an index.

    However, since you use the word AUTO_INCREMENT, I don't think this is SQL
    Server at all. Have you considered asking in a forum dedicated to your
    database platform?
    > What would be the pluses and minuses of keeping the indexes in realtion to
    > my ASP page work?
    In general, indexes:

    - speed up sorting, bookmark lookups, and joins
    - slow down inserts

    With uniques in particular, they help to keep redundant data out of your
    database.

    So, as I said before, the "pluses and minuses" really depend on your
    objective(s).

    --
    [url]http://www.aspfaq.com/[/url]
    (Reverse address to reply.)



    Astra Guest

  5. #4

    Default Re: Do I need INDEXes when a UNIQUE has been set?

    > What I'm trying to understand is that isn't the unique already doing the
    job
    > of the index, so do I really need to create a separate index as well for
    > each of the fields/columns?
    I thought I addressed that already:

    "In SQL Server, this would be redundant, since a unique constraint is
    implemented as an index."

    I'm assuming SQL Server, but you still didn't tell us which database you're
    using.

    --
    [url]http://www.aspfaq.com/[/url]
    (Reverse address to reply.)


    Aaron [SQL Server MVP] Guest

  6. #5

    Default Re: Do I need INDEXes when a UNIQUE has been set?

    Hi Aaron

    It's a MySQL 4 DB.

    Rgds Robbie

    Aaron [SQL Server MVP] <ten.xoc@dnartreb.noraa> wrote in message
    news:#Y7TzmKdEHA.3632@TK2MSFTNGP09.phx.gbl...
    > What I'm trying to understand is that isn't the unique already doing the
    job
    > of the index, so do I really need to create a separate index as well for
    > each of the fields/columns?
    I thought I addressed that already:

    "In SQL Server, this would be redundant, since a unique constraint is
    implemented as an index."

    I'm assuming SQL Server, but you still didn't tell us which database you're
    using.

    --
    [url]http://www.aspfaq.com/[/url]
    (Reverse address to reply.)




    Laphan Guest

  7. #6

    Default Re: Do I need INDEXes when a UNIQUE has been set?

    Then you'll have to consult the MySQL folks. I've played with it but not
    enough to know how they implement UNIQUE CONSTRAINTs.

    --
    [url]http://www.aspfaq.com/[/url]
    (Reverse address to reply.)





    "Laphan" <news@DoNotEmailMe.co.uk> wrote in message
    news:41086723_3@127.0.0.1...
    > Hi Aaron
    >
    > It's a MySQL 4 DB.
    >
    > Rgds Robbie

    Aaron [SQL Server MVP] Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139