150 likes | 285 Views
Databases 103. Entities and Attributes. Two Entities. ENTITY( Primary Key , Attribute, Attribute2, Attribute3, Foreign Key ). CUSTOMER( Cid , Name, Address, DOB, Postcode, Allowed, Vid ) VIDEO( Vid , Name, Cast, Rating, Condition). Attribute = Name. Attribute = Postcode. Attribute = DoB.
E N D
Two Entities ENTITY(Primary Key, Attribute, Attribute2, Attribute3, Foreign Key) CUSTOMER(Cid, Name, Address, DOB, Postcode, Allowed, Vid) VIDEO(Vid, Name, Cast, Rating, Condition)
Attribute = Name Attribute = Postcode Attribute = DoB Entity = Customer Attribute = Address Attribute = CUSTID Entities and Attributes Attribute = Age Attribute = Title Entity = DVD Attribute = Condition Attribute = DVDID
Databases Two and Three Student Course Repeating Group
First idea ….. • STUDENT(student number, student name, DoB, Sex, course1, course2, course3) • COURSE(course number, course name, teacher number, teacher name) This is called a repeating attribute It is not allowed in First Normal form This is called a repeating attribute It is not allowed in First Normal form
First idea ….. • STUDENT(student number, student name, DoB, Sex, course number) • COURSE(course number, course name, teacher number, teacher name) This is called a repeating attribute It is not allowed in First Normal form This is called a repeating attribute It is not allowed in First Normal form
First Normal Form • STUDENT(student number, student name, DoB, Sex, course number) • COURSE(course number, course name, teacher number, teacher name)
First Normal Form No repeating attributes or repeating groups of attributes
Second Normal Form Key • No partial dependencies What does that mean? Student name and sex are dependent only on part of the key They are unrelated to Course no.
Second Normal Form • STUDENT(student number, student name, DoB, Sex) • STUDENT_TAKES(student number, course number) • COURSE(course number, course name, teacher number, teacher name)
Many to Many in Second Normal Form Student Course Link Student Course
Third Normal Form • No ‘non key’ dependencies In this case, teacher name is dependent on teacher no, not course number So we break the table into two
Third Normal Form • STUDENT(student number, student name, DoB, Sex) • STUDENT_TAKES(student number, course number) • COURSE(course number, course name, teacher number) • TEACHER(teacher number, teacher name)