Introducing DBML TablePartial — Reuse Fields, Reduce Repetition

We’re excited to announce a powerful new feature in DBML — TablePartial!

Now you can define reusable sets of fields, settings, and indexes and inject them into multiple tables with a simple ~partial_name syntax.

Why you’ll like it:

  • :white_check_mark: Write cleaner, DRY-er (Don’t Repeat Yourself) schema definitions.
  • :recycle: Reuse common fields like timestamps and user metadata.
  • :gear: Maintain consistency across your entire database with ease.

Start using TablePartial today to simplify your DBML projects and speed up your workflow!

:books: Read the full docs →

Thank you for your continued support and trust in our products.
From dbx team with :heart:

3 Likes

You can also read our Design Considerations on why we don’t choose the OOP-style table inheritance approach.

BUG discovered!

If you have a table which only contains a table partial, you’ll get the error “table must have at least one column”

another BUG

If you refer to a column in an tablepartial, you’ll get the error “table {tablename} does not have columnname {columnname}”

try this:

tablepartial bugdemo {
    justaname varchar(64) 
}

table customer {
  customerid integer
  ~bugdemo
}

table order {
    orderid integer
    customer varchar(64)

}

Ref: customer.justname < order.customer

[/quote]

Hi @Wilfred_van_Dijk ,

Thank you for your bug report.

We are working on a fix for the issue where a Table containing only TablePartial still get the error “table must have at least one column”.

Regarding the second bug, it appears that you have a typo if the snippet. You defined the column justaname in the TablePartial, but refered to justname in the Ref element instead.
However, after fixing the typo, we discovered another bug appeared in the snippet you provided, that is the column justaname in the TablePartial cannot have type with arguments (varchar(64) in this case) right now, and we are also working on a fix for this issue.

Once again, thank you for your report.

Tho Nguyen,
dbx team.

1 Like

thanks for your quick response

I discovered another problem with TablePartial

I have a schema with 60+ tables. All these tables are SCD type 2 tables so they have a lot of columns in common - ideal for TablePartial. So I created a TablePartial for these scd2 columns, containing 9 column definitions.

  • I started replacing the columns in the original table with this TablePartial
  • After a certain amount of replaced tables, the visual diagram disappears and it won’t come back. At first I thought this was a browser issue (Edge), but I reproduced it also in firefox.
  • No matter what I tried, I could not reproduce the visual diagram. The only option was to remove the TablePartial implementation

Thanks for reporting the TablePartial bugs! Due to our National Holiday, there’ll be a slight delay, but we’ll dive into fixes right after next week. Stay tuned, and feel free to ping us with any questions!

Hi @Wilfred_van_Dijk ,

Can you share your diagram link or the DBML content that caused the error? If you cannot publish it in this thread, you can send it via our support email, dbdiagram@holistics.io.

Thanks.

Hi @Wilfred_van_Dijk,

We have released a new version of dbdiagram to address these two issues:

  • Getting the error “table must have at lease one column” in a table that contains only table partials
  • Columns in table partials cannot have type with arguments

Now, tables are allowed to contains only table partials, and at least one of them must have columns. Also, columns in table partials can have type with arguments (e.g. salary decimal(10, 2) ).

Thanks again for your report.

I cannot reproduce the “disappearing diagram” problem which I mentioned before. Seems this is fixed also?

Hi @Wilfred_van_Dijk ,

I believe the “disappearing diagram” issue you had is because the columns in your TablePartials have type with arguments (e.g. email varchar(255)). If that is the case, then the “disappearing diagram” issue is also fixed in the new version.