Is it possible to have database tables without primary key? I am using spring-data-jpa and my database is oracle. Heard Oracle primary key set up takes more memory and it impacts performance. If we are using jpa a technical key annotated with @Id and indexed properly in the table will help to over come such memory issues ?
Asked
Active
Viewed 175 times
0
-
6*"Heard Oracle primary key set up takes more memory and it impacts performance"* where did you hear this? Whatever performance hit you might imagine you'd suffer it will be nothing compared to the impact of the data corruption you will **inevitably** incur in a database without enforced primary key constraints. – APC Apr 09 '20 at 13:05
-
I heard it from one of my friend. I wanted to confirm it with experts. Using jpa an entity class field can be annotated with@Id and adding an autogeneration annotation will solve the data corruption I guess. For example if my table name is Employee and there will be a autogenrated id field employee_id but this will not be a primary key in table. – JAVA_CAT Apr 09 '20 at 13:08
-
@APC there is another similar post I found. https://stackoverflow.com/questions/2515596/can-a-database-table-be-without-a-primary-key – JAVA_CAT Apr 09 '20 at 13:12
-
1And in that thread Quassnoi makes the same point in his answer. Technical keys like an auto-generated ID don't solve the problem if you don't also enforce the candidate keys with unique constraints. – APC Apr 09 '20 at 13:13
-
So I have to implement a unique index? what all I have to take care during the db design. – JAVA_CAT Apr 09 '20 at 13:17