-1

I have made relational database model using MagicDraw tool. Every cashier has their workTime type saved in enumerator:

enter image description here enter image description here

Then I generate DDL code and try to paste it into phpMyAdmin to generate DB but I get many errors. I tried to fix them by hand but errors are still here. So how should that check statement be written?

SQL CHECK statement

Errors: Errors

vytaute
  • 1,260
  • 4
  • 16
  • 36

2 Answers2

0

A check constraint isn't part of a column's definition, it's its own clause in the table definition. You need a comma between the worktime char(13) not null and the check.

Mureinik
  • 297,002
  • 52
  • 306
  • 350
  • According to the [manual](https://mariadb.com/kb/en/constraint/#check-constraints): "CHECK(expression) given as part of a column definition." is one of the two valid forms of check constraint. One of the examples given is `b INT CHECK (b>2)`. – Damien_The_Unbeliever Feb 24 '21 at 09:58
0

I think I have found a solution.

A book that I was following to create DDL from MagicDraw project suggested to pick "Check Constraints" as an "Enumeration transformation strategy" when transforming model. It didnt worked that way so I have chosen "Lookup tables" instead and DDL code seems to be working now.

However it still had some erorrs. I had to add semicolons after all INSERT statements. enter image description here

And I also had to delete word "precision" after every 'double' type: delete

It works now.

vytaute
  • 1,260
  • 4
  • 16
  • 36