-
Notifications
You must be signed in to change notification settings - Fork 102
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
Displaying relations with or without crow's foot #166
Comments
Hi @michi-zuri You're right, we should show a one-to-one relation if the foreign key target a unique column (alone in pk or unique constraint). On the relation comments, I though about it and could easily add it in AML but what is more tricky to me is to integrate it in the UI. For now you can't select a relation and they are too thin to handle hover and click events. For the collapsed view, I hesitated between the actual implementation and attaching them to the sides. Will give it a try and see how it goes. Thanks a lot for your feedback, you're helping making Azimutt better 👍 |
hey @loicknuchel, yeah that seems right. Don't forget to think of composite unique constraints though, they are a thing in dbms systems. Not sure if AML supports those. You're very welcome for the feedback, thank you for keeping this software growing, it's a work of art! |
For now composite unique constraints are well supported in Azimutt (unless you tell me otherwise ^^), that's why we need to check the foreign key reference a single column constraint to be a one-one. In AML, you can have a composite unique like this:
If the unique key has the same name (after the |
Ah cool, thank you for pointing me to the documentation, I find it perfectly clear. I just realized now that I actually need a composite unique constraint in a join table where an additional id pk is added to the defining fks. By adding the extra id column one can avoid the need for composite foreign keys if one wants to reference the relation object in yet another table). Probably easier to follow with an example:
I noticed here that the current visibility of the unique constraint is quite limited if a fk constraint exists as well on the same column like in the example above (no difference between fk+unique and only fk). I personally would give precedence to the unique constraint when deciding which icon to show, because the fk is obvious from the arrows pointing out on the side. Would it be possible to add a little number footnote for composite uniqueness? The first unique group would have a 1 as footnote, the second unique group a 2, no group would have no footnote. As for your question, how to visualize composite fk constraints, tricky yeah. Maybe by obviously merging the lines close to the origin and target in a merge point like this? Oh and Here's another idea for the schema analyzer, should probably open a separate issue for this:
|
Lot of good ideas here, and lot of work ahead ^^ Just to keep this clear, here's the list of proposed ideas:
|
Hey @loicknuchel, yeah I'd be thrilled to contribute code if I could. Unfortunately I haven't come much further than hello world in Elm so far, but this could be the opportunity to dive in. Which one do you consider the easiest for beginners? I have dabbled in vanilla php and vanilla js... I may try to start with the fk icon priority. |
That's a big project to start but if you want to learn Elm that's a good opportunity 😉 We try to keep the project easy to work with but as we don't have many contributors for now, it may have some rough edges, feel free to report any difficulty you may have (for the setup as well as understanding the code) so we can figure out how to improve it 💪 Indeed, I think the easiest one is fk icon priority (Table.elm#L331, should be easy but a good first step in the project 😉) Other easy ones should be:
If you have any trouble to setup the project (it needs the Elixir backend as well as the Elm stack) feel free to ask. I will soon add a |
Dear Loïck and Samir
I like how you use the crow foot notation for one-to-many relations.
For one-to-one relations it doesn't look good, however. Here's an example:
As you can see, the chick hatches from one egg and since the fk chick.id (to egg.id) is itself a primary key, there cannot be more than one chick from one egg. To adapt this model to the real world (with the possibility of having twin chicks from one egg) the chick would need a pk separate from the egg.id. I would propose that the crow foot is not shown if the fk is itself the sole (not composite) pk, instead showing a vertical line (for one) like so, following the gist of crow's foot notation:
I would also like to be able to attach comments to relations like so, which causes an error right now:
fk egg.mother -> mother.id | one mother chicken may lay many eggs
Also note: in collapsed view I am missing the crow's feet and the curved lines!
see also https://azimutt.app/bba7e0f1-71cc-4f2b-be3d-ac470178d186/40bbceda-fab9-451e-83fa-b617226d4090?layout=relations&token=8d0c79bc-c7ee-4ca0-9b5e-3713041f27db
The text was updated successfully, but these errors were encountered: