====== SPM-Level Computer Science ====== It turns out, Computer Science (CS) for SPM (Malaysia Certificate of Education @MCE) deals mainly with database and web interface. I have developed database-related systems before, but I was doing it without having formal class on it. Basically, I simply wing-it based on what I know on how computers store data (i.e. C data types). I need to help my son with some questions, so I looked up 'database normalization' and found some things. The good thing is the way I implemented my database is mainly the 'correct' way. The not-so-good thing is that I am NOT able to help my son much with the practice questions - simply too many terms that I am not familiar with. Just shows that implementations need not be theoretically developed - experience (and good fundamentals) can also help to produce relatively sufficient results. Anyways, the main reason I am writing this here is to 'store' the following 'note' (for my personal future reference). Database Normalization Five 'rules' to make data normal: 1NF,2NF,...,5NF (NF=normal form) - each rule builds on another, starting from 1NF - 1NF/2NF/3NF -> Core Basics (normalization usually means 3NF!) - 4NF/5NF -> Exceptions *Note: Normalization is about grouping & connecting data the right way! 1NF is about - atomic values - unique identifiers *Term: Imagine a spreadsheet -> [table] or [entity] 1NF rules - a cell cannot contain more than 1 value = if it does, that column needs to be split into multiple columns - each row (@record) must be unique = look for potential primary key = usually, we use system-generated (integers are better!) - each column name must be unique - there must be no repeating groups (or cells?) = it there are, remove and create new table (1NF!) 2NF rule - all data/column(s) must depend on the primary key = if it does not, must be split into it own table (1NF!) = use primary key in new table as column value -> foreign key 3NF rule - primary key must define all non-key column(s) = non-key column(s) must not depend on any other key = if this is not met, must create new table and use foreign key to link {{tag>computing}}