Maowl Open Maowl

Layers in a database model

Working with a large database? Split it into layers so you can focus on one part at a time. You might keep billing apart from inventory, or today's tables apart from a proposed change. Layers also make it easy to combine several models into one.

The Layers tab

Open the Layers tab in the side panel, or press L. Click New layer and type a name for it. To rename a layer later, double-click its name. Each layer has an eye that shows or hides it and a lock that stops its contents from being selected or moved. Drag layers up or down, or use Move up and Move down, to change their order. Show all and Hide all at the top apply to every layer except Notes and Columns. The layer you click becomes the active layer, where new tables go. Maowl remembers it for each model.

A table can be in several layers

When you select a table, the Layers section in the Edit tab shows a switch for each layer. Turn on as many as you need; a table always keeps at least one. A table is visible when any of its layers is visible, locked when any of them is locked, and drawn once, in the topmost of its visible layers. To put the selected tables in a single layer, choose that layer from Move to layer… below the switches.

A duplicate goes into the same layers as the original. Drag a foreign key out to an empty spot, and the new table joins the layers of the table you dragged from. Any other table you create or paste goes into the active layer. If that layer is hidden, Maowl shows it again so you can see what you added.

Foreign keys and layers

A new foreign key isn't in any layer, so its Layer dropdown in the Edit tab shows Default. The foreign key is visible when both of its tables are, and locked when either of them is. To put it in a layer, pick one from the dropdown. It's then visible only when that layer and both of its tables are visible, and locked whenever the layer is. To take it out again, choose Default. If you delete the layer, the foreign key is moved or deleted along with everything else in it.

Deleting a layer

When you delete a layer, you choose what happens to its contents: pick another layer under Move contents to and click Move and delete, or click Delete contents. Tables that also belong to another layer stay there either way.

Two built-in layers

Layers and import

Every import goes into a new layer. Name it under Layer for this import in the Import dialog, or leave the field blank to use the imported model's name. When you drop a file, its name is filled in for you. With Add to the open model, everything the import brings in goes into that layer, so hiding the layer hides what the import added. When an imported table merges into an existing one, the existing table joins the import's layer as well and stays in its other layers. The imported model's layers aren't carried over, but File › Open… keeps a file's layers as they are.

Layers and export

In the Export dialog, Visible layers only is on by default and leaves hidden layers out of every format, so you can export the CREATE TABLE statements for just one part of your database. Turn it off to include everything. A JSON export then remembers whether each layer is shown, hidden, or locked, so the model opens just as you left it.

Related