Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Is it not a good practice to display primary key on UI?

Badam123Mar 13 2018 — edited Mar 15 2018

Hi All

Presently we get device details though a feed where multiple devices can be mapped to single CustomerId. The device details are loaded in table : TBL_DEVICES . The devices presently do not have any natural primary key so we have created a sequence as primary key . We had a new request to assign a unique key for each device so that they can be searched from the UI using the unique key (Presently they can search using CustomerId) . The team has asked me to create a new column and increment using a sequence .

TBL_DEVICES  ( Existing structure)

-----------------

DEVICE_ID         NUMBER  PRIMARY KEY using Sequence

CUSTOMER_ID  NUMBER  FOREIGN KEY

DEVICE_DESC  VARCHAR2(100) 

CAPACITY         NUMBER

Can't we use the existing primary key as a unique key? . When I asked the same they said that showing primary key on UI is not a good practice . I was not convinced as it doesn't make sense to add a column and sequence which adds no value.

Please suggest.

Thanks

Comments

sb92075
Please realize that we don't have your tables & we don't have your data.
Therefore only YOU can run bechmark tests to see for yourself what produces the better results.
EdStevens
userPrasad wrote:
I am using oracle 10g. I have a table with huge data. There are 4 indexes on this table with combination of columns. All the indexes are created using the script like -
CREATE INDEX INDX1 ON My_TABLE
(ID, emp_NUMBER, emp_sal, emp_div)
TABLESPACE my_IDX
PCTFREE 10
INITRANS 2
MAXTRANS 255
NOLOGGING
NOPARALLEL;

CREATE INDEX INDX2 ON My_TABLE
(ID, emp_NUMBER, emp_name)
TABLESPACE my_IDX
PCTFREE 10
INITRANS 2
MAXTRANS 255
NOLOGGING
NOPARALLEL;

and so on...
Few columns are always there in every index like Id, emp_number.

Most of the select queries are using the id and emp_number in the where clause criteria's. SQL "select" performance is not very good and need to find some kinda solution to this problem .

Shall I create one index using all the columns present in various indexes instead of various indexes with different combination of the columns ?
CREATE INDEX INDX2 ON My_TABLE
(ID, 
 emp_NUMBER, 
 emp_name)
and

CREATE INDEX INDX2 ON My_TABLE
(emp_name, 
 emp_number,
 ID)
Both have the same collection of columns, but they most defianetly do not serve the same purpose. Once you understand that, you will have your answer.
1 - 2
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Apr 12 2018
Added on Mar 13 2018
29 comments
2,481 views