Database = Data Model + Data Instance + Application Logic Database Management System Postgresql IBM DB2 SQL Server MYSQL MariaDB Neo4J Excel MangoDB BigTable MsAccess Relational Database Management System Relational Data Model --------------- Relational Data Model Database = a set of relations ---- A relation (table) = a set of tuples ---- {A,B,C} = {B,A,C} = {A,B,C,C,C,B} A tuple = a set of attribute/value pairs Students(RIN, FirstName, LastName, Major, Class, Address, DoB, Advisor, Email) Classes(Code, Topic, Title, Instructor, Semester, Year, Section, NumStudents, Classroom, CRN) --> 1 Rule: attributes can only simple values Key: A set of attributes in a relation such that no two tuples can have the same value for the key, and no subset of the attributes is a key. Key for students? RIN Email Assume RIN is a key: Students RIN Name Major Advisor ------------------------------- 1 Sibel CSCI Stewart 2 Rich ECSE Wen 1 Sibel ARTS Vamos Can a student have two majors? Yes Change key to RIN, Major Students(RIN, FirstName, LastName, Major, Class, Address, DoB, Advisor, Email) What is a key? A student can have two majors. A student can have two advisors. Key: RIN, Major, Advisor Email, Major, Advisor Classes(Code, Topic, Title, Instructor, Semester, Year, Section, NumStudents, Classroom, CRN) Key: Assume no cross listings and a single title, but multiple isntructors is possible CRN, Instructor Code, Topic, Semester, Year, Section, Instructor StudentPhoneNumbers(RIN, PhoneNumber) Can a student have multiple phones? Yes Can a phone be shared by multiple students? Yes Key: RIN, PhoneNumber