Using Writer to generate a database skeleton

Forum rules
No question in this section please
For any question related to a topic, create a new thread in the relevant section.
Post Reply
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Using Writer to generate a database skeleton

Post by Villeroy »

The attached Writer template helps to generate the SQL for a database with 5 tables linked by a one-to-many, many-to-many and a one-to-one relation. It has been tested with embedded HSQL and embedded Firebird (LibreOffice only).

[*] The picture shows the database relations as generated by the default values.
[*] The table allows you to modify the table names, the column names, column types and the start values of the auto-IDs.
[*] The frame contains the resulting SQL to create the whole database with tables and relations.

The SQL includes the foreign keys, the primary keys and some text columns for item names. Add column definitions as needed. You may delete the predefined text columns. Once the database has been created you may also add columns using the table designer.

LibreOffice only: You can not paste the frame content into Base's SQL window because it ignores the text fields. You have to paste the frame content as plain text into a Writer window or into a plain text editor. Using OpenOffice, you can paste from Writer directly into the SQL window.

When using Firebird, you've got to copy and paste each of the five CREATE statements one-by-one into the SQL window and execute. Using HSQL, you can copy the five statements and execute them all together.

After running the SQL successfully, select the tables section and call menu:View>Refresh Tables and clean up the relations window by dragging tables into the right positions.
Attachments
Create_Database_Tables.ott
Writer document with SQL to create a relational database of 5 tables.
(45.99 KiB) Downloaded 266 times
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