Normalisation Rules and Practical Application Geoff Leese January

  • Slides: 12
Download presentation
Normalisation Rules and Practical Application Geoff Leese January 2010

Normalisation Rules and Practical Application Geoff Leese January 2010

Normalisation and Rules of Normalisation • • – – Unique rows, no multivalued attributes.

Normalisation and Rules of Normalisation • • – – Unique rows, no multivalued attributes. All relations are in 1 NF. Second Normal Form (2 NF) • Each nonprimary key attribute is identified by the whole key (called full functional dependency). • • – • Normalisation: the process of converting complex data structures into simple, stable data structures. First Normal From (1 NF) Third Normal Form (3 NF) Nonprimary key attributes do not depend on each other (i. e. no transitive dependencies). The result of normalisation is that every nonprimary key attribute depends upon the whole primary key.

Functional Dependencies and Primary Keys • Functional Dependency – A particular relationship between two

Functional Dependencies and Primary Keys • Functional Dependency – A particular relationship between two attributes. – For a given relation, attribute B is functionally dependent on attribute A if, for every valid value of A, that value of A uniquely determines the value of B. – The functional dependence of B on A is represented by A→B.

Functional Dependencies and Primary Keys (Cont. ) • Functional dependency is not a mathematical

Functional Dependencies and Primary Keys (Cont. ) • Functional dependency is not a mathematical dependency. • Instances (or sample data) in a relation do not prove the existence of a functional dependency. • Knowledge of problem domain is most reliable method for identifying functional dependency.

Second Normal Form (2 NF) • A relation is in second normal form (2

Second Normal Form (2 NF) • A relation is in second normal form (2 NF) if any of the following conditions apply: – Every non-primary key attribute is functionally dependent on the full set of primary key attributes. • To convert a relation into 2 NF, you decompose the relation into new relations using the attributes, called determinants, that determine other attributes. • The determinants are the primary key of the new relation.

Third Normal Form (3 NF) • A relation is in third normal form (3

Third Normal Form (3 NF) • A relation is in third normal form (3 NF) if it is in second normal form (2 NF) and there are no functional (transitive) dependencies between two (or more) nonprimary key attributes.

Third Normal Form (3 NF) (Cont. ) • Foreign Key: an attribute that appears

Third Normal Form (3 NF) (Cont. ) • Foreign Key: an attribute that appears as a nonprimary key attribute in one relation and as a primary key attribute (or part of a primary key) in another relation. • Referential Integrity: an integrity constraint specifying that the value (or existence) of an attribute in one relation depends on the value (or existence) of the same attribute in another relation.

Example stage one Student entity Student_id (primary key) Student_name Student_address Where Student_phone_no Student_email_address Student_course_code_one

Example stage one Student entity Student_id (primary key) Student_name Student_address Where Student_phone_no Student_email_address Student_course_code_one Student_course_title_one Student_course_location_one Student_course_leader_id one Student_course_leader_name_one Student_course_leader_email_one Student_course_code_two Student_course_title_two Student_course_location_two Student_course_leader_id two Student_course_leader_name_two Student_course_leader_email_two are the problems?

Example stage two Student entity Course entity Student_id (primary key) Student_address Student_phone_no Student_email_address Course_code

Example stage two Student entity Course entity Student_id (primary key) Student_address Student_phone_no Student_email_address Course_code Course_title Course_location Course_leader_id Course_leader_first_name Course_leader_surname Course_leader_email Student_surname Student_firstname Student_address_house and street Student_address_district Student_address_town Student_address_city Student_address_postcode Student_phone_no Student_email_address First Normal Form – repeating group removed to form a new entity, multi-valued attributes decomposed. Second normal form?

Example stage three Student entity Course entity Student_id (primary key) Course_code (primary key) Course_title

Example stage three Student entity Course entity Student_id (primary key) Course_code (primary key) Course_title Course_location Student_surname Student_firstname Student_address_house and street Student_address_district Student_address_town Student_address_city Student_address_postcode Student_phone_no Student_email_address Course_Leader entity Course_ Leader_id Course_leader_first_name Course_leader_surname Course_leader_email Second Normal Form – “Course leader” set of attributes removed to form a new entity as they don’t depend on the course ID. Third normal form? Relationships?

The completed ERD (LDS in SELECT SSADM language!) I’m not sure about the “address”

The completed ERD (LDS in SELECT SSADM language!) I’m not sure about the “address” set of attributes – are you?

Further reading • http: //askgeoff. org. uk/ITSKILLS/Presentations /Hoffer 5 e_CH 10. ppt - Week

Further reading • http: //askgeoff. org. uk/ITSKILLS/Presentations /Hoffer 5 e_CH 10. ppt - Week 20. • Hoffer et al (2008), Modern Systems Analysis and Design (5 th edition) pages 352 -355 • http: //www. youtube. com/watch? v=u. O 80 f 642 LCY – Accent grates a bit, but otherwise OK! • http: //www. dbnormalization. com/examples