Edit: Be sure to release "Ctrl" key after selecting the multiple rows!
I wish to designate two fields to act as the "Primary" when viewed in combination.
e.g. 1st field is "Food Group", 2nd field is "Name". Group could be "Cake" or "Candy", while Name for either could be "Orange". So I could have a recipe for BOTH Orange Candy and Orange Cake.
I hope this makes sense... I'm change over from MSAccess and with it you simply held "Ctrl" and selected multiple fields, then right clicked for assigning the primary key. An earlier post mentioned this same procedure, but it's not working in my case. Thanks for any help.
[Solved] Primary Key(s) using two fields
-
- Posts: 7
- Joined: Sat Dec 17, 2022 1:21 am
[Solved] Primary Key(s) using two fields
Last edited by MrProgrammer on Wed Dec 21, 2022 4:09 pm, edited 2 times in total.
Reason: Tagged ✓ [Solved] -- MrProgrammer, forum moderator
Reason: Tagged ✓ [Solved] -- MrProgrammer, forum moderator
Jake, OpenOffice 4.1.13, Win10
Re: Primary Key(s) using two fields
You can Ctrl+Click to select multiple columns. Then mark them as PK.
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
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
-
- Volunteer
- Posts: 1558
- Joined: Wed Jun 24, 2015 12:56 am
- Location: Colorado, USA
Re: Primary Key(s) using two fields
Using string data as a Primary Key will often come back to bite you. Using your example you can store only one recipe for Orange Cake.
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
Re: Primary Key(s) using two fields
As Villeroy said, this should work.JakeRogers wrote: ↑Wed Dec 21, 2022 2:59 am ... I'm change over from MSAccess and with it you simply held "Ctrl" and selected multiple fields, then right clicked for assigning the primary key. An earlier post mentioned this same procedure, but it's not working in my case. Thanks for any help.
What kind of database are you using?
What state is it in?
AFAIK:
- If you are using an "embedded database" (created from scratch in Base) you should be able to use the procedure you outlined.
- If you connect to a spreadsheet file, you cannot designate a primary key at all, neither simple nor composite.
- If you connect to an Access database file, the PK is available but you cannot alter the configuration.
- If you connected to a separate DB server (running on your computer or accessed over network), you may have been issued limited rights to modify the database structure.
- If there is existing data, or the database is "in production" (accessed by other users, attached to some running service), changes to PK may be disallowed to prevent conflicting keys or other data integrity issues.
This is also an important piece of advice for data integrity reasons. If your database is intended for anything more than personal, private use, consider the implications of typos, trailing spaces and deviant spelling standards.UnklDonald418 wrote: ↑Wed Dec 21, 2022 7:33 am Using string data as a Primary Key will often come back to bite you.
-
- Posts: 7
- Joined: Sat Dec 17, 2022 1:21 am
Re: Solved: Primary Key(s) using two fields
Thank you all for your quick response and I have edited my initial post as solved... growing pains from MSAccess, I guess. The db has over 2000 records and it exists as .accdb file. My motherboard failed and now I'm locked (can view only... can't even copy and paste) out of an old licensed version of MSOffice, thus the transition to OpenOffice. I'll post this as separate issue to see if there are any ideas for salvage.
Jake, OpenOffice 4.1.13, Win10