← All posts

AML

The best language to design databases, just upgraded 🤯

by Loïc Knuchel on

If you already know AML, you know how easy it makes database design.

If you don’t, now is your chance to learn about it and improve your database tooling.

And if you think the title is too much, let us know better ones, we can’t find any ^^

Previously on AML

AML, or Azimutt Markup Language, is a very simple DSL made to design database schemas. Its first goal is allowing you to write your thoughts as fast as possible in a structured way. So, almost no keyword or special characters:

users
  id
  name
  email
  created_at

posts
  id
  status
  title
  content
  author -> users(id)

Of course, you may want to add more details afterwards, and you can:

users {color: blue}
  id int pk {autoIncrement}
  name varchar(50) index
  email varchar(100) unique check(`email LIKE '%@%'`) {tags: [pii]}
  created_at timestamp=`now()` {hidden}

posts {owner: teamCMS}
  id uuid pk
  status post_status(draft, published, archived)=draft index
  title varchar index
  content text | supports markdown formatting
  author int -> users(id)

The initial version was published more than 2 years ago, and aged quite well. The main goal of this new iteration was to migrate from Elm to TypeScript to provide better tooling, and improve a few things (see below).

What’s new in AML?

First, it has its own home page 😎

AML landing page

Then, in the language, not much changed. Look at the migration guide but in short:

  • relation keyword changed from fk to ref
  • attribute ref changed from table.column to table(column)
  • nested fields changed from column:nested to column.nested

This brings more consistency to the language. The biggest improvements were addition enabling new use cases and more flexibility:

  • relation cardinality
    • rel posts(author) -> users(id) (many-to-one)
    • rel profiles(id) -- users(id) (one-to-one)
    • rel projects(id) <> users(id) (many-to-many)
  • composite relations
    • rel member_rights(user_id, org_id) -> members(user_id, org_id)
  • polymorphic relations
    • rel comments(item_id) -item_kind=Post> posts(id)
  • properties
    • admins {color: gray, owner: teamA, tags: [pii, private]} (entity)
    • id bigint pk {autoIncrement, hidden} (attribute)
    • rel projects(owner) -> users(id) {onDelete: cascade} (relation)
  • types
    • type id (anonymous)
    • type label varchar(50) (alias)
    • type status (draft, public, private) (enum)
    • type position {x int, y int} (struct)
    • type age `range (0..150)` (custom)
  • namespaces
    • namespace my_schema (everything after will have this schema)

Have a look at the full documentation to get exhaustive view about this new version.

If you want to see how it looks like at scale, you can check this 800 lines schema from the e-commerce demo.

What’s the big deal?

The language improved and made new use case possibles, that’s nice!

But here is the real big deal: in addition to Azimutt editor, AML is now available as a standalone library on npm 🎉 So you can use it on your own (JavaScript) projects 🚀

It also has a great Monaco editor integration, allowing you to not only write AML but also have a full-fledged IDE for it, with syntax highlighting, completions, contextual errors and more…

Finally, all this made possible for us to build dialect converters from/to several dialects like: AML (of course!), SQL (PostgreSQL for now), Markdown (for doc), Mermaid, JSON… You can experience everything right into your browser with just one click ❤️

AML to PostgreSQL converter

Give it a try and tell us what you think about this new AML version, the additional tooling we made and the other languages you want to see in our converters 🤩

Azimutt Icon

Azimutt · Database explorer and analyzer

Hi there! We're building a Next-Gen ERD to help understand real world databases, with cool UI and privacy focus. You can read about our journey and what we've learnt along the way on this blog.