Tommi Lepola
10/27/2022, 5:55 AMName
, Tag
, Value
. The items also have a Type
field. The Type
field dictates the rest of the fields for the item.
▪︎ So the Name
, Tag
and Value
are independent of the Type
field.
▪︎ But if the value of Type
is Type A
, a few more fields are added for the item: IP
, Port
, Channel
. However, if the Type
has the value Type B
, the item has other fields added to it: Address
, Body
, Method
• The question:
◦ What kind of table(s) with what kinds of fields would you turn this spec into?
▪︎ One option would be to create one table where all Type
dependent values (IP
, Port
, Channel
, Address
, Body
, Method
) are nullable.
▪︎ Another option would be to create add a field into table for the item such as TypeDependentFields
, which would then be an object/class which would contain either IP
, Port
, Channel
or Address
, Body
, Method
.
• For example in TypeScript this could be achieved with union types: TypeDependentFields: TypeAFields | TypeBFields
, but Kotlin doesn't have union types.
• It'd be nice to have this kind of datamodel atleast between the frontend (React TypeScript) and the backend for simplicity
• Tech stack: Kotlin, Ktor, Exposed, PostgreSQLEndre Deak
10/27/2022, 6:07 PMTommi Lepola
10/28/2022, 5:59 AM