Matua Doc

Matua Doc

Creating a database in LibreOffice Base

Learning intentions

You should be able to create a new database file in LibreOffice Base, explain what the file stores, create a table with suitable fields, choose appropriate data types, and set a primary key.

You should be able to save the database in a sensible location, enter a small set of records, and check whether the structure is suitable for the problem.

You should be able to identify common setup mistakes and explain how to avoid them.

What LibreOffice Base is

  • LibreOffice Base is a database application that lets you create tables, forms, queries, and reports using a graphical interface.

  • It is useful when you want to build a small relational database without starting from command-line tools.

  • In this lesson, you are creating a database file and at least one table inside it as the starting point for later work.

  • The goal is to build a clear structure first, rather than rush into entering lots of data.

This lesson is about creating a database in LibreOffice Base. It is not the same workflow as creating an SQLite database with terminal commands or code.

Before you create the database

  • A database should be planned before you click through the software so you do not invent field names randomly.

  • You should know what information the system needs to store and what each table represents.

  • Start with one clear purpose, such as storing hotel bookings and guest details for one real-world problem.

  • Then list the fields that each record should contain, including a unique identifier.

  • Good planning reduces redesign later because your first table is more likely to be usable for data entry and queries.

For this lesson, use a hotel bookings system. Decide on the first table you will create, and choose four fields for that table before you continue.

Even when using a visual tool like Base, database design still matters. Software does not automatically choose good field names, keys, or data types for you.

Creating a new Base database file

  • Open LibreOffice Base and choose to create a new database rather than connecting to an existing one.

  • For a classroom project, an embedded database is usually the simplest option because the file stores the database setup in one place.

  • Base will guide you through creating the file before you start building tables using a short wizard.

  • After the wizard, save the database with a meaningful file name such as hotel_bookings.odb.

  • Save the file in the correct project folder from the start so it is easy to find, back up, and submit later.

  • Avoid vague names like database1 because they become confusing once you make more than one file.

Create a new LibreOffice Base database file. Save it with a meaningful name such as hotel_bookings.odb in your classwork folder or project folder.

The .odb file is the LibreOffice Base database document. It acts as the main file you open to manage the database project.

Understanding the start screen options

  • When the new database opens, Base shows areas for tables, queries, forms, and reports down the left side.

  • At the beginning, the most important area is usually Tables because that is where the data structure is created.

  • Queries, forms, and reports become useful later, but they depend on the tables being designed properly first with sensible fields and keys.

  • If the table design is weak, every later part of the database becomes harder to use.

  • This means your first job is structural, not decorative you are building the framework of the database.

Open the new database and look at the left sidebar. Find the sections for Tables, Queries, Forms, and Reports, then click on Tables.

Creating your first table

  • In the Tables section, choose to create a table in Design View so you can control the field names and data types yourself.

  • Design View is usually better for learning because it makes each design decision visible.

  • Give the table a clear name that matches one type of thing, such as Guest, Booking, or Room instead of a mixed or unclear label.

  • Each table should represent one entity, not multiple unrelated topics.

  • Add one row in the design grid for each field you need with a field name, data type, and optional description.

  • Keep field names short, specific, and consistent so other users can understand them quickly.

Create your first table in Design View. Give it a clear name and add five fields with sensible field names.

A good table name usually uses a single noun because each record represents one item of that type.

Choosing field names carefully

  • Field names should describe the data clearly, such as booking_id, guest_name, room_number, or check_in_date.

  • Good names reduce mistakes because users understand what belongs in each field.

  • Avoid field names that are too vague, such as info, data, or thing because they do not communicate meaning.

  • Avoid names that mix several values together, such as booking_details, when the information should be split into separate fields.

  • Consistent naming makes the table easier to read later when you build forms, queries, and reports.

Check the field names in your table. Rename any field that is vague, unclear, or too general so that every field name tells the user exactly what it stores.

Choosing data types

  • Each field needs a data type so Base knows what kind of value the field should hold such as text, number, date, or yes/no.

  • The data type affects what users can enter and how the data behaves when sorted or filtered.

  • Text fields are useful for names, addresses, and codes that should not be calculated even if they contain digits.

  • Number fields are useful for values that might be counted or calculated, such as room number or number of nights.

  • Date fields should be used for dates instead of plain text so the database can sort and validate them properly.

  • Yes/No fields are useful when the answer has only two states, such as paid or unpaid.

Set a data type for each field in your table. Make sure you use suitable types such as text, number, date, or yes/no where appropriate.

Choosing the wrong data type creates problems later. For example, dates stored as plain text are much harder to sort and validate correctly.

Setting a primary key

  • Every table should have a primary key so each record can be identified uniquely.

  • In Base, a primary key is usually set on one field in Design View before the table is saved.

  • A good primary key never repeats and should not be left blank because each record must be distinguishable.

  • Many classroom databases use an ID field such as booking_id or guest_id for this purpose.

  • Without a primary key, records can become difficult to update, link, and check accurately.

Choose one field to be the primary key and set it before saving the table. Use a field that will be unique for every record.

Saving the table and checking the structure

  • After adding fields and setting the primary key, save the table and give it a clear name if you have not already done so.

  • Base may ask whether you want it to create a primary key automatically if you have not set one yourself.

  • It is better to review the structure before entering data so mistakes are caught early.

  • Check the table name, field names, data types, and primary key carefully.

  • If something looks unclear now, fix it before many records are entered because changes become more disruptive later.

Save the table and review its structure. Check that the table name, field names, data types, and primary key are all correct before entering any records.

Entering sample records

  • Once the structure is saved, open the table and enter a small number of sample records to test whether the design works.

  • A short test is better than entering dozens of rows before checking the design.

  • Sample records help you notice missing fields, awkward names, or unsuitable data types while the table is still easy to change.

  • They also show whether the primary key and required fields behave as expected.

  • Enter realistic test data rather than nonsense values if possible because real examples reveal design problems more clearly.

Open the table and enter two realistic sample records. Use them to check that your fields and data types work properly.

Testing with realistic sample data is part of good database design. A table that looks correct in Design View can still be awkward when you actually try to use it.

Common mistakes when creating a database in Base

  • One common mistake is starting with poor field names and hoping to fix them later.

  • This causes confusion in queries, forms, and reports because unclear names spread through the whole project.

  • Another mistake is using the wrong data type, such as storing a date as text.

  • This weakens validation and makes sorting less reliable.

  • A third mistake is forgetting the primary key or choosing a value that may be duplicated.

  • That makes records harder to manage and causes trouble when tables need to be related later.

  • Saving the file in the wrong place is also a practical problem because it increases the chance of losing work or submitting the wrong version.

Look back over your table and fix any beginner mistakes you can spot, such as unclear field names, unsuitable data types, or a missing primary key.

Worked example: a simple hotel bookings table

  • Imagine you are creating a database for a hotel starting with the bookings being made by guests.

  • One suitable first table would be Booking because each record represents one reservation.

  • The fields might be booking_id, guest_name, room_number, check_in_date, and check_out_date.

  • In this example, booking_id would be the primary key because each booking needs a unique identifier.

  • guest_name would usually use a text data type.

  • room_number could use a number type, while check_in_date and check_out_date should use date types.

  • After saving the table, you could enter two or three sample bookings to confirm the structure works as expected.

If you are unsure about your own table, compare it with the worked example. Check whether your primary key is unique and add one extra field if your table needs more useful detail.

Table: Booking

booking_id      number/text key
guest_name      text
room_number     number
check_in_date   date
check_out_date  date

Review and reflection

  • Creating a database in LibreOffice Base is more than just opening the program and clicking save.

  • You need a clear purpose, a sensible file name, a well-designed table, suitable data types, and a reliable primary key.

  • If these choices are made carefully, the database is much easier to use later for forms, queries, and reports.

  • If they are made poorly, the problems spread through the rest of the project.

Close your table and reopen it. Make sure you can still see the correct structure and the sample records you entered.

Final Challenge: In LibreOffice Base, create a hotel bookings database. Save the .odb file with a meaningful name, build one table with at least five fields, choose suitable data types, set a primary key, and enter two sample booking records.

A well-made first table gives you a strong base for the rest of the database project. The aim is not just to make the software work, but to make the structure clear, accurate, and easy to explain.