Import tables and merge models
File › Import… brings in work you already have, either as a new model or into the one you have open. When tables have the same name, nothing merges until you say so.
Ways to import
-
Table definitions. Paste
CREATE TABLEstatements into the Import dialog, or choose or drop a.sqlfile. A schema file works, and so does the output ofpg_dump --schema-only,mysqldump --no-data, SQL Server's Script as CREATE, or SQLite's.schema. Every table becomes a card with its columns and their data types as written. A primary key on one column makes it Unique and Required, a primary key on several columns makes them Required,UNIQUEmakes a column Unique, andNOT NULLmakes it Required. Every foreign key, whether it's written in the column, in the table, or added later withALTER TABLE, becomes a line between the two tables, with its column. Indexes, views, data, and settings are left out. Maowl only reads the text and never runs any of it. - A list of names, one per line or cells copied from a spreadsheet. Paste it into the Import dialog, or press ⌘V (Ctrl+V on Windows and Linux) on the canvas. Each name becomes a new table, laid out in the same rows and columns as the list you pasted, in a layer called “Pasted names”. To fill in a table's columns from a spreadsheet, see Columns, data types, and keys.
- A Maowl model. Paste a model's JSON into the Import dialog, or click Choose file… and pick a JSON file.
- Drop files anywhere in the window. On a blank model, a file opens right away. Otherwise, the Import dialog opens with the file ready to import. Drop several files at once, and we add them one after another, each in a layer named after its file.
- A Neo4j database, for teams that also use Neo4j. Choose Neo4j database at the top of the Import dialog, run the two queries we provide, and paste the results. See Import a Neo4j schema.
Everything you import keeps its table names and column names exactly as written. If a file or pasted text isn't something Maowl can read, is empty, or is damaged, Maowl doesn't import it and tells you why. For a damaged model file, the message also names the first problem and where in the file it occurs.
Open as a new model or add to the open one
Choose Open as a new model to keep the import separate from the model you have open, or Add to the open model to combine the two. When you add, we place the new tables beside your existing ones, select them, and zoom to show the whole model. Either way, everything you import goes into a new layer. Name it in Layer for this import, or leave the field blank to use the imported model's name. Layers from the imported model aren't carried over.
To import without reaching for the mouse, press Enter in the layer field, or ⌘Enter (Ctrl+Enter on Windows and Linux) in the text box.
Merging tables with the same name
Whenever tables have the same name, in the import, in the open model, or across the two, Maowl asks whether to merge them and lists them, with both spellings where they differ (OrderItem / Orderitem). Merge combines each set into one table with all of their columns and foreign keys. Keep separate leaves every table as it is and highlights the duplicates in red.
What happens when tables merge
- Tables without a name are never merged.
- The open model's columns keep their order, and new columns are added at the end. An empty data type or example value is filled in from the import.
- When merging leaves two foreign keys with the same name between the same two tables, they become one. Other foreign keys from the import are added, and any that started or ended at a duplicate now connect to the merged table.
- A column that's Unique or Required in either model stays that way after the merge.
- Notes stay with what they're attached to. A note with the same text as one already on the merged table isn't added twice, and a note that would cover another is placed below it.
- When an imported table merges into an existing one, the existing table also joins the import's layer. Hiding that layer hides everything the import added, while merged tables stay visible in their original layers.
Reviewing differences
If the same column has a different data type or example value in the two models, Maowl shows you each difference before changing anything. Choose Keep (the default) or Use imported for each one, or settle them all at once with Keep all or Use all imported. Whatever you choose, you can undo the whole import in one step.