• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

diffrences between KEY, Index in mysql and postgres

 
Ramina Nibilian
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Im not getting what is diffrence between KEY and INDEX in Mysql
is there any difference between them ?
What is thier correspends in PostgreSQL
I mean if i want to port a db from Mysql to postgreSQL then what is replacer of INDEX and KEY

Thank you.
[ May 19, 2005: Message edited by: Bear Bibeault ]
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35269
383
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ramina,
A key makes a statement about uniqueness. Databases generally implement a key with a unique index. An index is to improve performance. There are two types of indexes. An index can force uniqueness (like an additional key) or allow duplicates.

So a table can have multiple indexes, but only one key.
 
Ramina Nibilian
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for reply
In my case Each table in Mysql have more that one key
associated with it in table definition. some tables has Index instead of Key but the indexes are more than one too.
but any of tham have just one primary Key ,
in summry :
EAch table has several key and just one "primary Key"
or each table has one or more Index , and just one primary key.

I want to port this database to PostgreSQL , what is correspond with KEY and INDEX of mysql in postgreSQL


Thank you
 
Ramina Nibilian
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Pleas some one help me on this
I searched in internet and found nothing which could help me
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35269
383
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ramina,
MySql lets you create a primary key with multiple columns, but not multiple primary keys. Having multiple columns in a primary key means at least one of those must differ in value. So "Female, Jeanne" and "Female, Ramina" would be ok. If the two were both unique keys, "Female" would be a duplicate and be rejected. I avoid the word primary because by definition there can only be one.

As far as I know, they map to the same thing in mySql and postgres. These are standard database concepts, so I can't imagine database vendors would implement them differently. (But I haven't actually used postgres.)
 
Masoud Kalali
Author
Ranch Hand
Posts: 531
Java Mac OS X Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use index declaration for both key and
inde of mysql in postgreSQL
so any key will become and index in postGRESQL and any index will become an index too.
Primary key will be untouched (they are unique Index)

hope it helps
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic