How can a table be a field type in jHipster jdl?

267 Views Asked by At

Tables

1

I'm having a problem generating these tables using JHipster jdl with mysql. I need to know if I can create a field with a table as type or if a field can have a JSON type and how. If there's any other solution feel free to contribute, Thanks in advance.

entity Note {
   Min Float
   Max Float
}

entity Product {
   price Note
   price2020 Note
   price2021 Note
   price2022 Note
}
1

There are 1 best solutions below

0
Gaël Marziou On BEST ANSWER

Your design should be expressed as relations

entity Note {
   Min Float
   Max Float
}

entity Product {

}

relationship OneToOne {
    Product{price} to Note
    Product{price2020} to Note
    Product{price2021} to Note
    Product{price2022} to Note
}

However, I seriously question your design to have one column/relation per year, it's more a spreadsheet habit and it just does not scale. Each year you will have to modify your database and code.

I would rather consider adding a relation table that maps a product/year to a price.