-
Notifications
You must be signed in to change notification settings - Fork 13
Hierarchy Implementation Proposal #793
base: master
Are you sure you want to change the base?
Hierarchy Implementation Proposal #793
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general I like the idea but it looks like it doesn't fulfill the requirements?
Cons: | ||
|
||
- Attribute overrides can only be done on the variety or cultivar level. | ||
- More complex insert and update logic. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But it would be hidden behind triggers? In general this sounds like a good idea, as we then don't need to keep Rust, maybe Python (E2E) and JavaScript code (scraper) in sync.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, and the view would act just like our plant table right now, we only extend it with some more properties.
I like the idea more and more. Remaining questions: What about backend compilation time? From rust we basically only see the view, don't we? How is the performance? How will we do the import? Will we have several CSVs for each hierarchy level? |
With Rust, we would handle it as a table. We need to adjust the
😬 Well, every insert/update in the plants table would need to check up to 5 other tables with these functions.
Since we want to replace the insert functions, our current implementation should work. It may be slower, but see my answer above. |
I mean for what we do at runtime: searching plants etc. |
To bring it shorter to an end: I think there are only two options: either like you imagine or with everything in plants (keys point to other rows in the same table). Can you please write the pro/cons between these two in the decision? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good thus far.
As usual here are a few things I noticed while reading over your changes.
@@ -34,6 +34,8 @@ See the [PSQL documentation](https://www.postgresql.org/docs/current/ddl-inherit | |||
|
|||
> Table inheritance is typically established when the child table is created, using the INHERITS clause of the CREATE TABLE statement. | |||
|
|||
> Rust Diesel isn't intended for that. To only select data from a specific table, and not include all child tables, we would need to use the `FROM ONLY` keyword, which is not implemented in Rust Diesel. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
> Rust Diesel isn't intended for that. To only select data from a specific table, and not include all child tables, we would need to use the `FROM ONLY` keyword, which is not implemented in Rust Diesel. | |
> Rust Diesel isn't intended for that. | |
> To only select data from a specific table, and not include all child tables, we would need to use the `FROM ONLY` keyword, which is not implemented in Rust Diesel. |
Sentences need to be written on separate lines according to our documentation guidelines.
|
||
[Example](example_migrations/one-table-per-taxonomy-view-functions) | ||
|
||
It's similar to `One table for taxonomy ranks and one for concrete plants` We are extending it with a view and custom functions to reduce insert and update complexity in the backend and scraper. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's similar to `One table for taxonomy ranks and one for concrete plants` We are extending it with a view and custom functions to reduce insert and update complexity in the backend and scraper. | |
It is similar to `One table for taxonomy ranks and one for concrete plants`. | |
We are extending it with a view and custom functions to reduce insert and update complexity in the backend and scraper. |
@@ -85,6 +87,46 @@ Cons: | |||
- Almost everything in the plants table needs to be nullable. | |||
- More complex insert and update logic. | |||
|
|||
### One table per taxonomy rank and one for concrete plants. + View and custom insert/update/delete functionality |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This title is a bit confusing in my opinion.
Pros: | ||
|
||
- Inserting new plants is easy. We only need to implement minor backend changes. | ||
- Properties overrides can be done on every level. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Properties overrides can be done on every level. | |
- Property overrides can be done on every level. |
Only if we can't find a match, the value should be written. | ||
- We can offset this issue by implementing insert/update functions. | ||
Since they are going to be complicated, long-term maintainability may be an issue. | ||
- Almost everything in the plants and parent tables needs to be nullable. (Is this a downside?) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I think so. If everything is nullable (even if this goes against our data model) we need to perform more manual integrity checks.
-- COALESCE function accepts an unlimited number of arguments. | ||
-- It returns the first argument that is not null. | ||
|
||
--todo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use English everywhere, even if you just leave notes for yourself.
This would help non german speaking team members to gauge your progress more easily when reviewing draft PRs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall I like the proposal if overriding plant properties on every rank is something that we need.
Select performance would be great if we use a materialized view. Currently we only insert our plants offline and never update them, so the materialized view would never need to be refreshed.
Or are we expecting that to change in the near future? (Inserting/updating plants live)
As far as I understand, maintainability will suffer a bit. Adding a new plant property would then additionally involve:
- Adding a new column to all plant rank tables (families, genera, species, varieties, cultivars)
- Updating the plants_view to include the new column
- (Maybe) updating the insert / update trigger functions to support the new column
Basics
close #X
, are in the commit messages.Checklist
(not in the PR description)
(exceptions are documented)
Review