Is it adviceable to keep all the columns in a table present in Oracle database as primary key or only putting index to the columns which are being used in query without any primary key?
-
A table present in Oracle database which will be having information about flights. According to the functionality of the table, only possibility of having primary key is by keeping all the columns as a primary key. Because it may contain duplicate values in all the columns except any one column in a given time which may vary for different records. The table is having 10 columns. Which will improve the performance, either keeping all the columns as primary key or keeping index for the columns used in query without having any primary key...
-
Answer:
You should always have a primary key in a table. In that case, I would never use 10 columns, but instead use an integer field with automatic numbering. To do that in Oracle, use either a trigger or a sequence which will automatically populate the primary key. See Oracle documentation: http://www.orafaq.com/wiki/AutoNumber_and_Identity_columns You probably should also create an index on the table to increase performance.
Erik Laliberte at Quora Visit the source
Other answers
This smells like a table built by a Java guy based on his object model. Instead, model the data based on the data. I know a little bit about flight data and I do not believe such a table really exists. If the app would like a 10 column view of the data that is fine. Abstract the data model accordingly for the OM. To answer your question, in Oracle (and Postgres), 99.9% of the time I have a system generated numeric surrogate primary key, and a unique key index on the alternate key (aka business key) to enforce uniqueness. There are exceptions when I dont follow this but I can not think of any that apply to fight data when modeled properly.
Andrew Hansen
No, it is not. Because the index will be huge and useless. If you index columns A,B,C,D,E, all the queries which do not have A as a condition will not be able to use the index.
Lucian Nutiu
Related Q & A:
- Which should be used after messing up clustered index? Update statistics, Reindex or Reorganize?Best solution by Database Administrators
- How to know the Oracle Database Name?Best solution by Stack Overflow
- How to add primary key from multiple table as a foreign key in a table in sql server 2008?Best solution by stackoverflow.com
- How to Connect to Remote Oracle Database through PHP?Best solution by Stack Overflow
- How to make collapsible columns for a table?Best solution by Stack Overflow
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.