Quiz

  1. Is there anything that can replace auto_increment?

    Do you mean for automatically assigning IDs? The only other common practice is to generate a id in such a way that in high likelihood is unique. MongDB uses timestamp, random value, and counter

    What did you have in mind?

  2. What's the difference between saying relationships and relationship set or entities and entity set?

    "Oppenheimer" is an entity and so is Barbie, and they are both in the Movie table, which is an entity set. That's the traditional terminology. (It's also traditional to use singular words, which also makes queries a little easier to read.)

    However, there are lots of contexts were the words are used less carefully.

  3. What do you mean by "set" Is a relationship set a relationship (one line), or the set of multiple relationships in a diagram, or a set of the involved attributes...? Similarly, is an entity set a single table, a set of all the items in a table, or a set of multiple tables?

    A set is just like the use in mathematics: a collection of things.

    The boxes in the ER diagram represent sets of entities. The lines represent sets of lines.

  4. Can you show an in-class example with the ALTER TABLE syntax? I'm a little confused about how to use it.

    Well, we've seen some examples in the ER diagram. W3 schools has some more. And we can look at the MySQL Syntax

  5. You mentioned that there can be only one director, but in some movies, there are actually two directors. How would we address this? I think we talked about this, but it might have slipped my mind...

    We could make the relationship many-to-many. I decided against this, mostly because I wanted a good example example of a 1-to-many relationship.

  6. I'm unsure how you enter data for the columns/tables in dbdiagram.io. Could we please go over that?

    We don't enter data using dbdiagram.io. We enter it in the usual way: ad hoce INSERT statements, CSV files, and, very soon, web applications.

  7. I don't understand how the two 1-many relationships translate to a many-to-many relationship, visually and intuitively? I understand how it works with the "<>" though.

    Let's draw out an example:

    • Cillian Murphy was in Oppenheimer and in Inception. 1 actor, 2 movies.
    • Inception starred Cillian Murphy and Leonardo Decaprio and Elliot Page. 1 movie, 3 actors

    Collectively, we have a many-to-many relationship between actors and movies

  8. I'm a little bit confused about ISA hierarchies. Could you explain what it does? / I would like to go over ISA structure in class.

    Sure! I'll probably stick to the on-campus vs off-campus student example, but as an exercise, figure out how you'd represent something like university info

  9. How would you tell if two entities had an 'ISA' relationship with multiple tables just by looking at the mysql code? Have we seen any examples of this in either the vet, wmdb, or movie_lens_db examples?

    We haven't seen any examples of ISA. It might come up in your projects, though.

    It might be possible to infer an ISA relationship from a ER diagram, but I would strongly suggest supplementing the ER diagram with textual documentation. Don't lean too heavily on tools and notation.

  10. I'm still unsure about when it's best to handle an isa hierarchy via a large table vs. joins.

    Convenience, storage, and efficiency. In fact, in my diabetes project, we have two different approaches.