4.10.3 Fundamentals of Databases (Normalisation)
暂无描述。系统推荐的高质量记忆内容,适合每天坚持背诵学习。
卡片预览 (19 张)
What is Normalisation
The process which helps to organise and structure a database in a way which improves efficiency and integrity
What advantages does Data Normalisation bring
• Reduces data redundancy • Reduces Data inconsistency • One change cascades across related record making modification simpler • Eliminates insertion/update/delete anomalies
What are insert anomalies
Where data cannot be added to a database because it depends on the presence of unrelated data (e.g. In a “Student-Course” table, you cannot add a new course until at least one student enrols in it, because the student ID (primary key) cannot be null.)
What are deletion anomalies
Where deleting a record unintentionally removes unrelated, valuable data due to poor normalization and data redundancy. (e.g. If a database lists students and their enrolled courses in one table, deleting the only student in a specific course unintentionally deletes the information about the course itself.)
What are update anomalies
data inconsistencies in a database occurring when redundant data is updated in some, but not all, records.
What are the disadvantages of normalisation
• If the data is mad too atomic, fields may become unmeaningful • A more complex database is made meaning that querying data is also more complex and potentially slower
What is meant by a dependency
A value that varies in line with another value
What are the conditions for 0NF
• Non-Atomic data • Repeating groups of data • A PK for each record
What are the conditions for 1NF
• No repeating geoups of attributes (2 of the same attribute) • Data is atomic • Each record must have a primary key
Process of 0NF –> 1NF
• Separate repeating groups of data into a seperate table. • Separate non-atomic values into separate attributes • Declare a primary key
What is meant by a partial key dependency
Where the value of a data field relies entirely on part of the primary key where the primary key is a composite key
What are the conditions for 2NF
• Must already be in 1st Normal Form • The must be no Partial Key dependencies
How do you identify and fix partial key dependencies for n partial dependencies
• First ask for each non-key attribute “if the primary key changes does the attribute value change • Make n new tables where for each new table the primary key is the part of the primary key that one of the field relied on.
What is meant by a non-key dependency
Where an attribute is determined by another attribute in a table that is not the primary key
What are the conditions for 3NF a
• Must already be in second normal form • Must have no non-key dependencies
How do you find non-key dependencies a
Ask yourself: “Is it ever possible for two records to have the same value in this field?”.
How do you fix non-key dependencies for n non-key dependencies
• Make n new tables, and for each one you should contain the non key dependency attributes
What is meant by atomic data
When each column has only one piece of data in it
Describe problems that can occur in database that is not fully normalised
• Redundant data may waste storage space • Data inconsistency where two copies of the same data store different values • No cascade updates meaning each copy of the same data needs to be separately updated if change • It may be difficult to select/edit data if it is not atomic or if there are repeating groups