We are starting a new project and I am looking for some guidance / best practice of how to implement Haystack in a relational database.
One option would be to have one large metadata table based on the grid format: rows are entities, columns are tag keys, cells are tag values. Time-series data would be stored in separate tables.
But this doesn't seem like a good database design. Is it better to have separate tables for site, floor, room, zone, equip and point entities?
Can you point me to some other DB implementation? I searched the website/forum but no luck.
Thanks, Karol
Brian FrankTue 13 Oct 2020
I have not actually done it, but I can give you some thoughts...
Many people use Haystack in Excel so looking at how people use Haystack with Excel can provide lots of ideas about how to flatten into 2 dimensional tables
Haystack in tables will often be very sparse with lots of empty cells
Most of the sparse cells are marker tags since most tags are markers; for example most points will have the same core set of tags such as kind, unit, siteRef, equipRef, but there will often be dozens of different marker tags used
If you do map tags directly to columns, then you should probably expect to be adding columns a lot (schema changes)
If you plan to make your system a true Haystack server and/or you want to query with Haystack filters, then it will be easier to map filters to an SQL expression if everything is one table
Using one table will probably also be easier to map Refs and ids to an auto-generated primary key
But also consider Haystack is probably more RDF like than SQL like, and RDF databases tend to store data as triples of subject, predicate, value (which in our case would be entity id, tag name, tag value)
If your application is mostly accessing the data via SQL, then having separate tables would probably be more natural
Karol JarolimekTue 27 Oct 2020
Hi Brian,
Thank you for your advice. We have decided to go with the more standard DB design with multiple tables. So we have the standard hierarchy of site->floor->zone->room->equip->point.
The only complication is that we had to attach weatherPoint to the rooms, because we consider solar radiation for the different facades.
Karol Jarolimek Tue 13 Oct 2020
Dear all,
We are starting a new project and I am looking for some guidance / best practice of how to implement Haystack in a relational database.
One option would be to have one large metadata table based on the grid format: rows are entities, columns are tag keys, cells are tag values. Time-series data would be stored in separate tables.
But this doesn't seem like a good database design. Is it better to have separate tables for site, floor, room, zone, equip and point entities?
Can you point me to some other DB implementation? I searched the website/forum but no luck.
Thanks, Karol
Brian Frank Tue 13 Oct 2020
I have not actually done it, but I can give you some thoughts...
Karol Jarolimek Tue 27 Oct 2020
Hi Brian,
Thank you for your advice. We have decided to go with the more standard DB design with multiple tables. So we have the standard hierarchy of site->floor->zone->room->equip->point.
The only complication is that we had to attach weatherPoint to the rooms, because we consider solar radiation for the different facades.
Best regards,
Karol