3

I personally don't like the idea of pushing the Job.ID value on all the other child tables Why not? The obvious solution is to make JobID the leading PK/clustered index column on all the child tables. And it ensures optimal performance for accessing all these tables by JobID. Generally whenever you have an "identifying relationship" aka "child table" aka ...


2

An example of how data integrity can be maintained using FKs. I have modified the model a bit to allow for an executable to be a part of more than one job. The assumption is that when an executable runs, it runs for all customers associated with that executable. Your ERD does not show constraints, so there is some guessing involved. -- Customer CUS exists....


1

I think the 2nd is better. Because I guess you should not allow a ProductUserCommentAction if there is no ProductUserComment.


1

I had just asked that on a different forum. The best solution for a 3rd Normal Form schema design was to select all that is needed in the linking table and compare the Cardinality (count) of the matching results. The other forum was for Oracle. The answer you seek is the PostgreSQL version of this post: https://community.oracle.com/message/15613817#...


1

Here's another approach: SELECT @usa := country_id from countries where iso_alpha3_code = 'USA'; insert into provinces (province_name, country_id) VALUES ('Alabama', @usa), ('California', @usa), ('Alaska', @usa); But I contend that you should not normalize country_code; simply use the standard 3-letter (or 2-letter) codes. The savings ...


1

Try this one with cte as ( select metric_id, value, datetime, ROW_NUMBER () OVER (PARTITION BY metric_id ORDER BY datetime desc) as rn from his_metric ) select n.ip, m.id, m.key, m_h.value, m_h.datetime from metric as m join node as n on m.node_id = n.id join cte as m_h on m.id = m_h.metric_id and m_h.rn=1


Only top voted, non community-wiki answers of a minimum length are eligible