Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Group the Joins and Relations sections in a dedicated chapter #8435

Merged
merged 8 commits into from
Dec 22, 2023

Conversation

DelazJ
Copy link
Collaborator

@DelazJ DelazJ commented Aug 11, 2023

Supersedes #7563
image

The last section, about widgets and forms, is not in the PR. Not yet sure what existing sections to move there and how to structure it but the idea is to have most of the form widgets that handle relations and joins described also in this chapter.

Fixes #7558, fixes #6205, refs #7709

No plans to backport!

@DelazJ DelazJ added Project/Configuration project properties, global options and settings Properties labels Aug 11, 2023
@DelazJ DelazJ mentioned this pull request Aug 11, 2023
1 task
@DelazJ
Copy link
Collaborator Author

DelazJ commented Aug 11, 2023

@ponceta ?

@ponceta
Copy link
Contributor

ponceta commented Aug 14, 2023

I'm a great fan of this! 👍

@3nids do you think this is a good way to go?

I got quickly over the builds artifacts and it looks good.

https://github.com/qgis/QGIS-Documentation/actions/runs/5836463495

@DelazJ
Copy link
Collaborator Author

DelazJ commented Sep 1, 2023

@3nids, may I? Thanks

Copy link
Member

@3nids 3nids left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good for me, some minor remarks

docs/user_manual/working_with_vector/joins_relations.rst Outdated Show resolved Hide resolved
docs/user_manual/working_with_vector/joins_relations.rst Outdated Show resolved Hide resolved
**Joins** allow you to associate features of the current layer
to features from another loaded vector layer.
Whether they are spatially enabled and their geometry type does not matter.
The join is based on an attribute that is shared by the layers, in a one-to-one relationship.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not always one-to-one I believe. One-to-many is also possible.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that I read again, I think I wasn't clear enough. I was referring to joins in QGIS (rewording suggested above). Is that possible to have a one-to-many join in QGIS? Does QGIS not only perform a left join? I'd be curious for the how-to.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I understand it, QGIS doesn't have a direct built-in one-to-many join operation for attribute tables. To achieve one-to-many relationship-like results, users need to use SQL queries or spatial databases. Therefore, there is no single workflow in QGIS for one-to-many joins. Consequently, I don't think one-to-many joins can be adequately described without external guidelines (such as PostgreSQL/PostGIS), and I'm not sure if that's something we want to include in QGIS documentation. @DelazJ, you may have more insight into the rules for external guidelines in QGIS docs.

Anyway, while I'm not an expert on spatial databases, I do know that Joins in QGIS allow relationships where features in one layer can be associated with features in another layer based on shared attributes. For instance, you could join a point layer representing cities to a table containing information about each city. Each city point can be associated with one record in the attribute table. Perhaps this is considered a one-to-many join, even if it's not a true one-to-many relationship in a relational database sense. In other words, is it possible that the terms 'one-to-one' and 'one-to-many' are misunderstood?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@selmaVH1 Thanks for the feedback and confirming that joins in layer properties only allow a feature to be associated to one other record.
Speaking of one-to-many relation, this is also possible in QGIS through the project relations but this is already addressed in the other part of the PR.

QGIS currently has support for joining non-spatial table formats supported by GDAL
(e.g., CSV, DBF and Excel), delimited text and the PostgreSQL providers.

.. is the above still true? No more supported formats (oracle, mssql, ...)???
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have thought that this is available for any data source.

Setting relations between multiple layers
=========================================

Unlike joins that define a one-to-one link between features across two layers,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is the difference (as stated above, joins are not strictly 1-to-1). To me the main difference is that relation offers a mean to navigate through the relations, in other words list and discover features which are associated to each other.


You should enable the transaction mode in :menuselection:`Project Properties --> Data Sources -->`
when working on such context.
QGIS should be able to add or update row(s) in all tables (airlines, airports and the pivot tables).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shall we suggest here to use UUIDs instead of increment?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry but I have no idea what you mean, @3nids

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@3nids I assume this refers to PostgreSQL, not QGIS?

Copy link
Collaborator Author

@DelazJ DelazJ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @3nids for the feedback
I tried to reply and integrate your various comments (as suggestions for the moment instead of commits). I'm honestly quite unsure of the joins IN QGIS allowing one-to-many cardinality so if you can share some evidences, I will (be unhappy to have to) refactor the PR accordingly.

**Joins** allow you to associate features of the current layer
to features from another loaded vector layer.
Whether they are spatially enabled and their geometry type does not matter.
The join is based on an attribute that is shared by the layers, in a one-to-one relationship.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that I read again, I think I wasn't clear enough. I was referring to joins in QGIS (rewording suggested above). Is that possible to have a one-to-many join in QGIS? Does QGIS not only perform a left join? I'd be curious for the how-to.


You should enable the transaction mode in :menuselection:`Project Properties --> Data Sources -->`
when working on such context.
QGIS should be able to add or update row(s) in all tables (airlines, airports and the pivot tables).
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry but I have no idea what you mean, @3nids

docs/user_manual/working_with_vector/joins_relations.rst Outdated Show resolved Hide resolved
docs/user_manual/working_with_vector/joins_relations.rst Outdated Show resolved Hide resolved
docs/user_manual/working_with_vector/joins_relations.rst Outdated Show resolved Hide resolved
docs/user_manual/working_with_vector/joins_relations.rst Outdated Show resolved Hide resolved
docs/user_manual/working_with_vector/joins_relations.rst Outdated Show resolved Hide resolved
docs/user_manual/working_with_vector/joins_relations.rst Outdated Show resolved Hide resolved
@DelazJ
Copy link
Collaborator Author

DelazJ commented Oct 17, 2023

@selmaVH1 May I request your review here, particularly on unresolved points raised by @3nids? Thanks.

@DelazJ DelazJ requested a review from selmaVH1 October 28, 2023 06:31
@DelazJ DelazJ added the backport release_3.34 On merge create a backported pull request to 3.34 label Dec 20, 2023
@DelazJ DelazJ merged commit f021603 into qgis:master Dec 22, 2023
4 checks passed
@DelazJ DelazJ deleted the workingWithRelations branch December 22, 2023 08:45
@ponceta
Copy link
Contributor

ponceta commented Dec 22, 2023

Many many thanks to you! This is a great improvement for the understanding of relation management in QGIS! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport release_3.34 On merge create a backported pull request to 3.34 Project/Configuration project properties, global options and settings Properties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Working with relations Relation section is within attribute table section
4 participants