=====
CS 325 - Week 6 Lecture 1 - 2021-09-27
=====

=====
TODAY WE WILL
=====
*   announcements
*   start the intro to entity-relationship modeling, part 2
*   prep for next class

*   New reading for this week:
    *   DB Reading Packet 5 - E-R modeling, Part 2
    *   SQL Reading Packet 4 - sub-selects, concatenating columns and
        projecting literals

*   Homework 4 is available! Should start working on that; due Friday, 11:59 pm

=====
*   extensions to the E-R model, and just some additional points
    to make -- that's the purpose of the packet for E-R modeling, part 2

*   for example: recursive relationships!
    ...that is, just note that it is OK for a relationship line to
       begin and end on the same rectangle,

       to say there is a relationship ampongst entity instances of the
       same entity class

=====
Weak entities
=====
*   is one whose presence is REALLLLLY strongly dependent on the
    existence of another entity class (typically one)

*   don't take this too far;
    not really for association entity class situations (I'll get to those)

*   different notations exist for this, our CS 325 standard will be to put
    these in a double-bordered rectangle

*   interesting rule of thumb: if it is truly a weak entity class,
    its instances should be existence-dependent on at least one instance
    of its parent class (better be a hash/1 on the relationship line on
    the parent end of the relationship line...)

*   it is pretty common for a weak entity class to not have any
    identifying attributes (but that's also true for association entity
    classes)

=====
Supertypes and Subtypes!
=====
*   Supertype entity classes and subtype entity classes
    were brought in as a significant part of the so-called
    extended E-R model (added after Peter Chen's initial 1976 paper)

    *   The original E-R model handled HAS-A relationships well --

        A sale has a customer, (a sale sells to a customer)
	A course has students, (a course enrolls students),
	etc.

    *   BUT! It was found that the original E-R model did NOT
        handle IS-A relationships as well;

        A savings account is an account,
	A checking account is an account;

        ...so the E-R model was extended, and one of the major extensions
	was adding the concept of supertype entity classes and subtype
	entity classes.

    *   when? for example:
        *   particularly useful when a sub-category of a significant
	    set of "things" has attributes that only that sub-category
	    should have (as well as the usual attributes for that "thing")

            ...maybe savings accounts have an interest rate, but other accounts
	       don't;

            ...maybe checking accounts have a per-check charge, but other
	        accounts don't

        *   particularly useful when a sub-category of a significant
            set	of "things" has relationships that only instance of
	    that sub-category should have (as well as the usual relationships
	    for that "thing")

            ...maybe all accounts have an opened_by relationshio with
	       a customer entity class,

            ...but only checking accounts have a relationship with a
	       tax report entity class, say, but other accounts don't

    *   (be sure to see the DB Reading Packet 5! and the
        associated screen-shot image for a scenario with Accounts,
	Savings_Accounts, and Checking_Accounts --
	
        We walked through a discussion of that -- on the Zoom recording!
	-- and I drew an E-R diagram, but didn't get very many typed
        projected notes here)