Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tis5X-003Dgf-LA for pgsql-general@arkaria.postgresql.org; Fri, 14 Feb 2025 09:34:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tis5U-006Moz-Nx for pgsql-general@arkaria.postgresql.org; Fri, 14 Feb 2025 09:34:21 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tis5U-006Mor-9K for pgsql-general@lists.postgresql.org; Fri, 14 Feb 2025 09:34:21 +0000 Received: from mail-yw1-x1129.google.com ([2607:f8b0:4864:20::1129]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tis5T-000jyq-06 for pgsql-general@lists.postgresql.org; Fri, 14 Feb 2025 09:34:20 +0000 Received: by mail-yw1-x1129.google.com with SMTP id 00721157ae682-6f4bc408e49so14806437b3.1 for ; Fri, 14 Feb 2025 01:34:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1739525658; x=1740130458; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=fKX+XRkj7BN4NPfuTM2ktqks8soEABep73NQF+wbW0U=; b=PYYi4r+qx4Nt9LBV4rpwp3mrXWVaB9M9+FxhVg1oHLuDly9UCU1X0XQMiIiCOl3vE3 68F6JqRyD8qr3hJRDFGH31K/YMQOl2xBwDnY4RK/87rkNfAeMyL06HOgfYxZ10hrQxop S/DWJpIxY5lusyYefEuIsWycpTjit4VkCkgDuDm6KRy31zuM+GAyEVgUlpPSq4+uNv36 IG3RlD2jO9G/wl0qMYLU64JLS2IZaUszQjt7vbx7n5O6bffQxSl431ZVLhqdSJaoxE50 FxBrI8SqH3LlKJ5f/MzPm6R8+U+sG4J0fW75yfB+JJlzqXe85cFVKgi0EArFCssxVQdd JZhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739525658; x=1740130458; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=fKX+XRkj7BN4NPfuTM2ktqks8soEABep73NQF+wbW0U=; b=AuAY4kRRa9o69YebDkhAacY2XZwEaK4kig8fcb/GGcDs/SsWZN75+iplw5vTDTMWkk o4chwvSP/0s/kmiiCzEEwCf/736SoLj2S7cjzHwEHrC5OTbMH58J2JJclgRhoPm3watM 0h8qvCM4FmvXHNz3JPjYVHENfGTBKXDAslN9Y+IjkDLDQ2RVnYFIZL3loiJgRPnyn4J6 6jLCoHpFkLfn1gTOl2cDuF7mwhFfUqdTZaFJ2xQ0Vb0fOLwpKiu/nH72DSivj1Dp6Yxz O8QbyoUU8qS9rO5yBOHgj4/Y4PWVGFGnx5W1WWCeposzM68EjPdVhaFnFdoWSzHTC5x1 oZtg== X-Gm-Message-State: AOJu0Yya+nrtuzu9lglfuwUDisDTl1GWn3q40P0+S/g+U5ZRm9sqNh6C Tli1f0zZlAMD/SWxc6TDzDfqQI37P73zzV6Z9X9yye/Z7G1eRhi1lMYXkkZGJzUFrY46W7J2/Dr WyecTogchO+fNuLQxk8njseNFGwAVYov7+3c= X-Gm-Gg: ASbGncvBpGUL1pSGw+BOWo+JhjFqRo/cg0I+iBOO/NfD97m/+eZMcuq5OdoCnzRv48M oaypVCY9WuJiK49PZx52Qyn6TCkESq2Cq6I77BP/KsWdfgt5OWO5QPjhgx76ghCvzY/2M6hccd/ Q= X-Google-Smtp-Source: AGHT+IF25orM/FWsiui+Zyuw6sp4orzPWkwzhPekog9nsV/WZ53Bkf1bJSpRQ8gFpmtwBnWeN2C60S4l07ZTVQlmhPE= X-Received: by 2002:a05:690c:9983:b0:6f7:409c:f645 with SMTP id 00721157ae682-6fb1f171dc7mr87915117b3.4.1739525658013; Fri, 14 Feb 2025 01:34:18 -0800 (PST) MIME-Version: 1.0 References: <8d2dd92a-da16-435b-a38e-fe72191fc9d1@cloud.gatewaynet.com> In-Reply-To: From: Allan Kamau Date: Fri, 14 Feb 2025 12:34:00 +0300 X-Gm-Features: AWEUYZn1-2fOLwInFN5BRLiJwGz7ZFraDW7yv_rd9RgdA9wgvnbxTNMVpTJ3cXw Message-ID: Subject: Re: Ideas about presenting data coming from sensors To: Thiemo Kellner Cc: "pgsql-generallists.postgresql.org" Content-Type: multipart/alternative; boundary="000000000000ec7c65062e16e018" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000ec7c65062e16e018 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Feb 13, 2025 at 9:44=E2=80=AFPM Thiemo Kellner wrote: > 13.02.2025 10:54:05 Achilleas Mantzios - cloud < > a.mantzios@cloud.gatewaynet.com>: > > > If we followed a strict normalized approach then we would create > additionally 11 tables each tag of type c) . And we are not guaranteed th= at > the same tags would have the same structure over the whole > fleet/manufacturers. So we are thinking of putting all semi-structured da= ta > of tags of type c) into one table with a single col of type jsonb . From > what I read timescaledb plays nice with jsonb (or at least not bad). > > > > Do you ppl see any gotcha with this approach ? > > > > For starters we will not convert yet to timescaledb, but store them and > handle them like normal tables. At least until we grasp the ins and outs = of > this. > > I have not come to see the real advantage of putting data into something > like Jason or XML columns. Sue, you make life easier initially saving the > time to put them into columns one by one, on the other end you have the > hassle of dissecting the JSON, XML you name it when you retrieve/select t= he > data, every query. While the query might stay stable the computational > effort dissection will have to be done with every query execution. > > For c) you could go to 6th normal form, or what number that is, by a tabl= e > like TAG(id, tag_name, tag_value). You would have to convert the values t= o > string to enter them. It is a pain in the butt, imho, retrieving them > again. You can alleviate by having a specific column/table per data type, > e.g. TAG(id, tag_name,tag_value_varray,tag_value_date,...). > > What is the downside of having each a table for the special tags? More > effort in setting up. > The upside is less effort in retrieval, and a much more understandable > model. > > If your tag structure is volatile, you might have generic column names on > a table mapping them in a view to speaking names. Taking this further doe= s > anchor modelling https://www.anchormodeling.com/ > . > > > Though you haven't asked for comments on database design, I have a suggestion, have you considered using table partitioning based on a well defined date interval, maybe monthly? Here your DB data population application will determine the name of the table based on the current date then check for the existence of the table and then construct the inherited table if one does not exist and proceed to populate the child table accordingly. This may prove useful in future. -Allan. --000000000000ec7c65062e16e018 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Thu, Feb 13, 2025= at 9:44=E2=80=AFPM Thiemo Kellner <thiemo@gelassene-pferde.biz> wrote:
=
13.02.2025 10:54:05= Achilleas Mantzios - cloud <a.mantzios@cloud.gatewaynet.com>:

> If we followed a strict normalized approach then we would create addit= ionally 11 tables each tag of type c) . And we are not guaranteed that the = same tags would have the same structure over the whole fleet/manufacturers.= So we are thinking of putting all semi-structured data of tags of type c) = into one table with a single col of type jsonb . From what I read timescale= db plays nice with jsonb (or at least not bad).
>
> Do you ppl see any gotcha with this approach ?
>
> For starters we will not convert yet to timescaledb, but store them an= d handle them like normal tables. At least until we grasp the ins and outs = of this.

I have not come to see the real advantage of putting data into something li= ke Jason or XML columns. Sue, you make life easier initially saving the tim= e to put them into columns one by one, on the other end you have the hassle= of dissecting the JSON, XML you name it when you retrieve/select the data,= every query. While the query might stay stable the=C2=A0 computational
effort dissection will have to be done with every query execution.

For c) you could go to 6th normal form, or what number that is, by a table = like TAG(id, tag_name, tag_value). You would have to convert the values to = string to enter them. It is a pain in the butt, imho, retrieving them again= . You can alleviate by having a specific column/table per data type, e.g. T= AG(id, tag_name,tag_value_varray,tag_value_date,...).

What is the downside of having each a table for the special tags? More effo= rt in setting up.
The upside is less effort in retrieval, and a much more understandable mode= l.

If your tag structure is volatile, you might have generic column names on a= table mapping them in a view to speaking names. Taking this further does a= nchor modelling https://www.anchormodeling.com/
.



Though you haven't asked for comme= nts on database design, I have a suggestion, have you considered using tabl= e partitioning based on a well defined date interval, maybe monthly?
<= div>Here your DB data population application will determine the name of the= table based on the current date then check for the existence of the table = and then construct the inherited table if one does not exist and proceed to= populate the child table accordingly.
This may prove useful in f= uture.

-Allan.

--000000000000ec7c65062e16e018--