1. 39

  2. 6

    I was learning SQL over the summer, and I found the venn diagrams very confusing. Unlike /u/pab, I think the visualization from this article explains it much better.

    1. 8

      Referencing users on lobste.rs is done with @, not /u/, e.g. @Forty-Bot.

      1. 2

        hm, well profile pages are still at lobste.rs/u/<username> so I don’t know why they changed it.

        1. 6

          What do you mean changed it? @ is the de facto standard way to mention usernames. It has always been that way on lobste.rs and everywhere else I can think of, the only place /u/ works is reddit.

          1. 2

            @ originated on Twitter & has been widely copied but I suppose that Reddit is actually now more widely used than Twitter.

            1. 5

              @username format predates Twitter.

              1. 4

                @name was around before Twitter (as plaintext markers in emails), and @name references are common on many social media sites (including Facebook).

                1. 1

                  What’s a plaintext marker in email? Never heard of it.

                  Some MUAs with html email allowing you to embed simple text or something?

                  1. 4

                    I mean literally including @Name in the text of an email when sending a message to a group of people and including parts directed at specific people. Not specially parsed by software at all.

                  2. 1

                    Facebook copied it from Twitter, as I said.

                    1. 2

                      My point is that @name is in far, far more common usage than /u/name. I should have been clearer.

                  3. 3

                    I suppose that Reddit is actually now more widely used than Twitter.

                    Citation most definitely needed.

                    Maybe in raw “engagement numbers” or whatever weird metrics ad people use to track site sizes, but Twitter is more mainstream than Reddit. A lot of Redditisms don’t even make sense to people outside it: the /r/ and /u/ prefixes, the distinction between link and self posts, and the threading (believe it or not, most people find threading super-confusing).

                    The gosh-darn POTUS has a Twitter account. I doubt he’s even heard of Reddit.

                    And in any case, it’s not whether /u/username or @username is more “popular”, the plain fact of the matter is that this site uses @username, and nothing else. As does Twitter, Discord, MS Teams, and for all I know Slack. Reddit is the outlier in this case.

                    And finally, there’s no reddit,com/u/username page, it redirects to reddit.com/user/username.

                    (Edit removed over-use of the word “definitely”).

                    1. 2

                      You are correct on all counts. I was even mistaken about my belief that Reddit is more popular than Twitter; evidently that’s only true in the US: https://www.alexa.com/topsites/countries/US

                      1. 1

                        I appreciate your response.

                      2. 1

                        And finally, there’s no reddit,com/u/username page, it redirects to reddit.com/user/username.

                        Writing /u/username in on reddit does several things. First, it sends a notification to that user. Second, it is displayed as if it was written [/u/username](https://reddit.com/user/username). There is similar behaviour for referencing subreddits with /r/subreddit. This native support strongly suggests that reddit considers reddit.com/u/username as a valid way to refer to a user’s profile, and to mention them on the website.

                      3. 2

                        But lobsters is written in ruby like Twitter and Reddit is python.

                        1. 1

                          I’m pretty sure there’s an implied sarcasm identifier that’s not printed there.

                          At least I really hope there is.

              2. 3

                This is, I am almost ashamed to admit, the first time I understood SQL joins.

                1. 3

                  Now I’m curious. Can anyone recommend other visual representations of JOINs?

                  1. 2

                    Tables are probably the best way to illustrate joins. Cf https://en.wikipedia.org/wiki/Relational_algebra#Joins_and_join-like_operators

                    1. 2

                      Unfortunately my database doesn’t have an antijoin keyword.

                      1. 1

                        From the same blog: https://blog.jooq.org/2015/10/13/semi-join-and-anti-join-should-have-its-own-syntax-in-sql/

                        Apparently Impala supports it, but in other database you can get the same result using one of:

                        • SEL … FROM R LEFT OUTER JOIN S ON R.key = S.key … WHERE S.key IS NULL
                        • SEL … FROM R WHERE R.key NOT IN (SEL key FROM S)
                        • SEL … FROM R WHERE NOT EXISTS (SEL … FROM S WHERE S.key = R.key)
                        1. 2

                          r.key NOT IN (SELECT key FROM s) is not equivalent to NOT EXISTS (SELECT 1 FROM s WHERE s.key = r.key) - you can observe that when “s” contains a NULL “key”.

                          1. 1

                            Yes, the blog post I linked above mentions that you have to take special care if NULLs are present.

                  2. 2

                    I completely understand the point and one could argue that Venn Diagrams shouldn’t be used in higher education but when I first got taught about SQL at school, I was 13, it made learning joins much easier to visualize.

                    Plus they are pretty darn close to what those joins do AND the way it is represented in the article is not really visual, it’s just explaining joins with yet more tables.

                    I’d suggest the following title:

                    “Say Maybe to Venn Diagrams When Explaining JOINs (use them cautiously)”

                    1. 2

                      The row based visualaization may be more accurate, but it’s much harder to identify. Whenever I’ve used a map of Venm diagrams, it was to go from visualization to query. It’s very easy to pick out the one with middle and the right, or both sides but not the middle, etc. The row diagram forces me to stare and count to find the one I’m looking for.

                      1. 2

                        When teaching, it is always useful to have more than one way to explain a problem. Different but equivalent (or nearly equivalent) models work better for different people.

                        1. 2

                          I hadn’t thought about this until reading the article, but it seems as if the Venn diagrams are accurately representing something. If you take the full outer join as your starting point, then the Venn diagram represents which elements are retained, by projecting the elements of the full outer join onto the underlying relations A & B. Is that right?

                          If so, then I think they’re ok. While the actual mathematical explanation of the Venn diagrams is complex, I don’t think most readers are concerned with it. Or put another way, the diagram is correct from a perspective of maximum pedantry or minimum pedantry, but incorrect if you’re being mildly pedantic.

                          As far as teaching people, I think that the Venn diagrams are somewhat useful. Joins aren’t intrinsically hard, there’s just a lot of different options, and they’re not super-memorable (cross join vs. outer join, or left vs. right, for instance).

                          1. 3

                            The Venn diagrams (when they overlap) represent operations among sets of the same (“union-compatible”) type. As the author points out, SQL includes these operations UNION, INTERSECT, and EXCEPT.

                            A SQL join is a product among sets of possibly differing types. Using a Venn diagram to illustrate a SQL join only makes sense if your join key is covering, or if you are ignoring all non-key attributes.

                            1. 1

                              I think you misread me. I described a way of reading the Venn diagrams as representing things of the same type, namely subsets of the full outer join.

                              1. 2

                                Perhaps so! If I now understand what you mean such diagrams would have one circle (the subset) fully enclosed within another (the full outer join). That’s an interesting perspective, but it doesn’t define the meaning of “full outer join.”

                                1. 2

                                  Good point. I’m coming at this from the perspective that what’s tough isn’t the concepts, just keeping the variants straight.

                                  That makes me more sympathetic to the article. If you’re trying to bootstrap an understanding of what a join is, the Venn diagrams are a potentially confusing metaphor/illustration.

                          2. 0

                            I don’t get it. This article says that Venn diagrams are not useful for visually explaining joins. But then the author visually explains the one type of join that nobody needs to use, and then explains how all the joins (that are actually explained with Venn diagrams) are really just [insert LaTeX relational algebra here] of the joins which we have explained. I am all for a more faithful model, but you’ve got to have something to offer.

                            1. 7

                              All the join types are illustrated, not just cross join, so you should probably look more carefully.

                              1. 1

                                I am missing how all join types are illustrated also. I looked pretty carefully, so could you explain?

                                I wonder if there’s a miscommunication or something I’m not seeing on my mobile device or what.

                            Stories with similar links:

                            1. Say no to Venn diagrams when explaining JOINs via unbalancedparentheses 2 years ago | 9 points | 1 comment