Paulene:We’ll be talking about normalisation and going through to 1st Normal Form.The best example would be to look at a physical adaptation of data and what happens to it.Show an example of a physical order card on the board – explain that we cannot just dump this into a file in a drawer, to prevent searching through files and files of paper, this should be put into a database to help with: (ask the class what the benefits would be): IE: Fast Queries, Multiple Users, Portability, Flexibility, LongevityLet them come up with some suggestions and then go onto next slide...
Briefly sum up these points or if the class guessed most of these correctly then probably just read them out again.
How do we turn this Order Card into an actual database design?3 Steps1. Identify the candidate keys2. Select the primary key3. Apply NormalisationIntroduce Mo...Mo:Each one of these fields is better known as a data element/attributeThe reason we call it a key is it becomes a key to that record – to finding that person, etc...Which of them, if any or how many of them are uniquely identified? Meaning no other order could have the same value.Can u find a candidate key in this example?IE...Order Number would be a candidate key (no other order could have the same value)If there’s more than 1 candidate key, the winner would be the Primary Key (this is the element that would be used to find records) The selection of the winner is usually determined by which one is used more often to find records.Its also used to link 1 database to another.(May need to explain why customerNo & itemNo are not candidates in this example – if anyone asks) (1 order = 1 customer, 1 order = Many Items) Items is repeating)The last key that we’ll talk about later is the foreign keyIf we were to define the relationship between 1 db and another, what always must be true is that there must be 1 common data element between them to form a relationship.Typically, u’ll see that duplicate element is between primary keys, they point to each other, they have a linkage and that's what creates the relationship itself.Sometimes, as you’ll see today, there are relationships that we want to form between 2 tables that do not have that natural link and thus we must create one. – Which is what we call the foreign key.
Then we need to apply Normalisation – so what is this?Talk about removal of data redundancyTalk about IntegrityThis will become clearer as we go through an example in the next lessonIntroduce Brian...
In order for a database to achieve 1NF, there must be no repeating elements.It is very difficult to understand how Normalisation works from this description, this is why learning how to apply normalisation is such a challenge.
A file in logical modelling is basically called an entity.Data Elements are called Attributes.OrderNo would be PK –Explain Dependency. OrderNo is basically controlling all of the other attributes. IE: If the key changes, all of the other elements change with it. A change in order number changes the record we are looking at.Graph on right:We have a logical view of the form, showing the primary key and with its non-key attributes surrounding it.
In table format:Are we in 1NF?1NF says no repeating elementsDo we have repeating elements? – YES!Item No, Item price, Item Qty, etc...are a repeating groupWe failed 1NF which means we have an integrity problem.Whenever u fail a Normal Form, u must create a new entity. ...Introduce Fatemah...
Class were handed an attribute (data element) each at beginning. Now they are to stand up and organise themselves into 1NF.
Show on board if they’ve got it right – and ask one of them to explain their reasoning. Congratulate if they were close or got it right and then explain the above on next slide...
What do we do when we fail in NF?The 1st Rule!Create a new entityWhenever u fail a 1NF, the new entity will have what is known as a concatenated primary key. Part of this rule is that the new primary key will be a concatenation from the entity that failed, which is the OrderNo.So we will take Order no and concatenate it with ItemNo. So the new entity will be called orderItemsPrimary Key is: OrdernNo, ItemNo1stEnity will keep the orders2nd Entity will have all of the items associated with that orderWhat we’ve discovered is that ItemNo is not a non keyed attribute – it is part of a primary key and therefore the elements that depend on it must go with it (ItemName, ItemPrice, ItemQty, ItemAmount)These are all dependencies of the itemNo.We now have 1NF!! Conclusion:You can also break this down further up to 3NF, which is the industry standard.Any more – come see us!
Normalisation lesson plan
Normalisation Paulene Fatemah Brian Mohamed
ORDER CARD OrdersOrder No:Order DayCustomer NoCustomer NameCustomer AddressItem No Name Qty Price TotalTotal Amount:
Benefits for creating a database?Fast Queries FlexibilityMultiple Users LongevityPortability
3 Steps OrdersOrder No: 001Order Day 24/01/11 Identify theCustomer No: 501 candidate keys?Customer Name: Jeff BlogsCustomer Address: 34 Street Select theItem Name Qty Price Total primary keyNo110 Pizza 1 £2.00 £2.00 Apply111 Chips 4 £1.00 £4.00 NormalisationTotal Amount: £6.00
NormalisationA set of rules to ensure a database is ordered in the best possible wayRemoval of data redundancyIntegrity
1st Normal Form No repeating elements/groups/data
OrdersOrder No: 001 TotalOrder Day 24/01/11 AmountCustomer No: 501 Order DayCustomer Name: Jeff Blogs OrdersCustomer Address: 34 Street ItemNo OrderNo - PKItem Name Qty Price Total Item NameNo Item Qty Customer Customer No Name110 Pizza 1 £2.00 £2.00 Item Price111 Chips 4 £1.00 £4.00 Customer Item Total AddressTotal Amount: £6.00
1NF?Order Order Cust Cust Cust Item Item Item Item Item TotalNo Day No Name Addrs No Name Qty Price Total Amnt001 24/01/ 501 Jeff 34 110 Pizza, 1, £2.00 £2.00 £6.00 11 Blogs Street 111 Chips 4 £4.00 £4.00002 24/01/ 502 Fred 20 110 Pizza 2 £2.00 £4.00 £4.00 11 Luke Road Remember: No repeating elements/groups/data
Interactive Task Using the cards on your desk , stand up and organise yourselves into 1NF.Remember: Whenever u fail a Normal Form, u must create a new entity. No repeating elements/groups/data
1NFOrders - TableOrderNo OrderDay Cust No Cust Name Cust Address001 24/01/11 501 Jeff Blogs 34 Street002 24/01/11 502 Fred Luke 20 RoadOrder Items - TableOrderNo ItemNo Item Name Item Price Item Qty Item Amount001 110 Pizza £2.00 1 £2.00001 111 Chips £1.00 4 £4.00002 110 Pizza £2.00 2 £4.00
What do you do when you fail in1NF? Create a new entity The new entity will have a concatenated primary keyOrders - TableOrderNo OrderDay Cust No Cust Name Cust AddressOrder Items - TableOrderNo ItemNo Item Name Item Price Item Qty Item Amount
A particular slide catching your eye?
Clipping is a handy way to collect important slides you want to go back to later.