Database table with multiple fields

Discuss the database features
Post Reply
jayrobb
Posts: 2
Joined: Tue Feb 15, 2022 2:29 am

Database table with multiple fields

Post by jayrobb »

I am making a table in my data base:

Date:
Statement#:
Load#:
other stuff...
then fuel:

one statement can have multiple loads and each load can have multiple fuel entries

how do I make tables inside of tables?

thank you
Open Office 4.3.1, Windows 11
FJCC
Moderator
Posts: 9623
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: database table with multiple fields

Post by FJCC »

You should make multiple tables. One table would have the Date, Statement Number and perhaps other information. A second table would have the Load Number and a Foreign Key relationship between the Statement Number of the first table and the same Statement Number stored in the second table. Similarly, the third table would have the fuel information and a foreign key relationship with the Load Number. Every row of the second table would be associated with one row of the main table via the Statement Number. This is known as a 1:N relationship. There would also be a 1:N relationship between the Load Number table and the Fuel table.
In queries, you would join the first table to the Load Number table, requiring that the Statement Numbers match, to see all of the Load information associated with the selected Statement Numbers. Another join would be used to match Loads and Fuel information. I suggest you read a tutorial about a Normalized Database. It is well worth the effort to get the database design correct from the beginning.
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
User avatar
Villeroy
Volunteer
Posts: 31363
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Database table with multiple fields

Post by Villeroy »

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
Post Reply