entity, noun, most important actors/aspects of a web site's data to be stored start with core nouns first to build a list of entities you will need and refine later
attribute, noun, an aspect of an entity that is data to be stored in both cases we want to store "data at rest" NOT "data in motion" number of favorites is data in motion that counts the data at rest
Ryan favorited @jsaul Dylan favorited @jsaul
each of these individual entries in the database is data at rest how many people favorited @jsaul? data in motion because that answer can changed at any time
relationship, verb, an interaction that exists between two entities
relationships are purely semantic and exist because one sees an interaction in the user story/use case/interaction flow as necessary to the product to formulate a relationship, define these three variables:
1, well, ummmm, one? n, an entity that ocurred n times, n ≥ 0 m, an entity that ocurred m times, m ≥ 0 and m ≟ n use these quantities to then judge how many times this relationship can occur: 1 profile can sell n properties: 1-to-n 1 profile can have 1 avatar: 1-to-1 m profiles can favorite n tweets: m-to-n each quantity must be used twice, one per entity and this will cover the most general of cases - deriving exact values for m or n is not necessary Indexes & Keys
index, noun, a data structure in SQL that allows for faster searching
unique, noun, an index that forces values to never repeat
primary key, noun, an immutable unique index that is the primary identifier mutable, adjective, the ability to modify data after it's created
foreign key, a copy of a primary key from a "foreign" entity used in relationships
foreign keys are the mechanics of how relationships work and put the concept into actual code and enforce referential integrity, the idea that data is consistent Foreign Key Assignment foreign keys should be placed base on relationship: 1-to-1: choose one (not both) 1-to-n: choose the n entity m-to-n: create another entity called a weak entity with BOTH keys in the weak entity, BOTH keys are declared as a primary key OR: x or y is true when either is true - red or green? :red-chile: :green-chile: XOR: x xor y is true when one or the other is true - dead or alive? ☠️