Search Postgresql Archives

Indexes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Another little doubt:

I've already asked that in #postgresql at freenode, but I didn't
understand well.

I have two tables:

Books
- book_id
- name

Authors
- author_id
- name

One book can have many authors and one author can have many books. To
make that possible, I need a third table:

Intermediate
- book_id
- author_id

My question is about the indexes in Intermediate table. Is the
following index:

CREATE UNIQUE INDEX foo ON Intermediate(book_id, author_id);

enough for every query I want to perform? Or should I need

CREATE UNIQUE INDEX foo ON Intermediate(book_id, author_id);
CREATE UNIQUE INDEX bar ON Intermediate(book_id);
CREATE UNIQUE INDEX baz ON Intermediate(author_id);

too?

Thank you very much. Bye!



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux