Ask Your Question
0

How to auto-populate a field that isn't the primary key

asked 2016-03-25 21:04:38 +0200

b2683152 gravatar image

updated 2016-03-25 21:08:48 +0200

Hi,

I am trying to use Base to make a database to catalog a collection of books, audio, and video files. My database currently has 4 tables:

Tables: Books, Audio, Video, Index

The Index table has the fields "Global_ID", "Title", and "Category", with the Global_ID being the primary key. This table is meant to hold a list of everything (books, audio, and video titles, as well as a unique identifier for every record). The Category field is a text field that says what type of item the record is (book, audio, video).

The Books, Audio, and Video tables each have 2 fields, (BookID, Global_ID)(AudioID, Global_ID)(VideoID, Global_ID).

How can I relate these tables such that each item has its own primary key (ID) within its own table, but all items have a unique Global_ID that is unique across all tables?

Would my data entry to add new items be done in a form based on the Index table? And How would BookID, AudioID, and VideoID be automatically generated in the corresponding tables when I create records in the Index table?

I have tried opening up the relationships window and creating linking each tables primary key to the Global_ID in the index table, as well as trying to make BookID, AudioID, and VideoID fields in the Index table and linking each tables primary key to the similarly-named field in the Index table.

Thank you.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2016-03-25 21:53:09 +0200

Ratslinger gravatar image

Your approach seems to be overly complex. I would reduce this down to one table. Unique ID, Media Type, Name (and I might add things such author, year, etc.). Media type can be a list box with a choice of 'Book', 'Audio' and 'Video' to help eliminate typing.

Now when you want to view in a form, you can filter the table results with Media Type and only show those entries for say 'Video'. Or create a search on name and display what Media Types are available.

edit flag offensive delete link more

Comments

Thanks for your reply. The reason I was trying to set it up this way is because I plan on also keeping track of things like number of pages for books, author, as well as runtime, rating, size, etc for video and audio. Should I put all of these in one big table?

b2683152 gravatar imageb2683152 ( 2016-03-26 00:49:18 +0200 )edit

Well I can see it both ways. Since the size of this DB will be relatively small (not 10's of thousands of records) one record for all should work. Going the other way ( 4 tables ) all you need to do is link the 'Name' from 'Index' table to 'Name' in each of the other tables. Each has a one-to-many relation ('Index' to other table). However, combining records from multiple tables ( IE: a search/query) will be a challenge since each has different content.

Ratslinger gravatar imageRatslinger ( 2016-03-26 02:18:08 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2016-03-25 21:04:38 +0200

Seen: 138 times

Last updated: Mar 25 '16