[Solved] Primary key

Discuss the database features
Post Reply
IreneEng
Posts: 19
Joined: Thu Jul 27, 2017 10:00 pm

[Solved] Primary key

Post by IreneEng »

Hi everyone,

In a table, I'd like to have an auto filled field (like, an ID) but I don't want to have it as my primary key (I'd like to use it as say, name of a book for my library table). But OO doesn't seem to like my idea. Is there a better way to do it?

Thank you so much in advance.
Irene
Last edited by Hagar Delest on Fri Jul 28, 2017 10:44 pm, edited 1 time in total.
Reason: tagged [Solved].
Apache OpenOffice 4.1.2
Windows 10 ... I think
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Primary key

Post by Villeroy »

A name is not suitable as a primary key. Simply use the auto-value. A primary key should be a unique value that points to a distinct row so any other table having a foreign key just needs the simple and completely meaningless book number to identify all the other attributes of a book.
A name is not a small value. A name has many bytes, therefore it is not suitable for really fast lookups.
A name is not unique. Two books can have the same name.
A name is not meaningless like an auto-ID. An auto-ID serves the one and only purpose to be a unique identifier for some item. You can change any attribute of your book while the unique identifier always points to the same book.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
IreneEng
Posts: 19
Joined: Thu Jul 27, 2017 10:00 pm

Re: Primary key

Post by IreneEng »

Thank you V!!
Apache OpenOffice 4.1.2
Windows 10 ... I think
Post Reply