Ask Your Question

One to many relationship "how can I display a field different from the primary key"?

asked 2016-03-06 03:08:09 +0100

celf gravatar image

updated 2020-07-12 18:44:26 +0100

Alex Kemp gravatar image

I am creating a new database and I have 2 tables.

Table1 ( Games) = PK GameID Title FK CategoryID

Table2 ( Categories) = PK CategoryID Category

As you can see, the category table has a list of game categories

The Games table, uses the CategoryID as the foreign key. However, that foreign key is an autonumber field. I would like to be able to select a category for each game and have it be readable. For example a category of RPG, or Platformer. How can I setup my tables correctly, so I can just type the category instead of the number of the key from the category table.

Please excuse me, I am very new to databases. I am using LibreOffice Base with Linux Mint 17.3

edit retag flag offensive close merge delete


1 Answer

Sort by » oldest newest most voted

answered 2016-03-07 01:46:36 +0100

Ratslinger gravatar image

In your first table you only need the categories so CategoryName (ie:RPG) will be unique & set as primary key. In second table names are not unique so set a numeric auto field as primary key (creates uniqueness). Then a field with GameCategory (ie: RPG) and other fields as wanted. Then create a relationship with CategoryName in first table to GameCategory in second table (one-to-many relation). Do that from main Base screen Tools->Relationships. With that you can use form wizard (or design your own) to create entry & display forms.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2016-03-06 03:08:09 +0100

Seen: 828 times

Last updated: Mar 07 '16