1 / 37

Database Concepts

Database Concepts. Advanced Source: OCC; teach-ice; devshed - An-Introduction-to-Database-Normalization /. Flat-File vs Relational DB. Flat File Database

luigi
Download Presentation

Database Concepts

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Database Concepts Advanced Source: OCC; teach-ice; devshed- An-Introduction-to-Database-Normalization/

  2. Flat-File vs Relational DB • Flat File Database • A flat file database is a database designed around a single table. The flat file design puts all database information in one table, or list, with fields to represent all parameters. A flat file may contain many fields, often, with duplicate data that are prone to data corruption. • There is no automation between flat files. If you have two or more flat files that contain client addresses, for example, and a client moved, you would have to manually modify the address parameters in each file that contains that client’s information. • Changing information in one file has no bearing on other files.

  3. Relational Databases • A relational database, on the other hand, incorporates multiple tables with methods for the tables to work together. The relationships between table data can be collated, merged and displayed in database forms. Most relational databases offer functionality to share data: • Across networks • Over the Internet • With laptops and other electronic devices, such as Palm Pilots • With other software systems

  4. Normalization • In the field of Relational Database design, normalization is a systematic way of ensuring that a database structure is suitable for general-purpose querying and free of certain undesirable characteristics—insertion, update, and deletion anomalies—that could lead to a loss of Data integrity

  5. Data Integrity • Refers to the validity of data • The assurance that data is accurate, correct and valid to the validity of data

  6. What is Normalization? • Database normalization can essentially be defined as the practice of optimizing table structures. Optimization is accomplished as a result of a thorough investigation of the various pieces of data that will be stored within the database, in particular concentrating upon how this data is interrelated. • Advantages: • the speed in which the tables are queried, • in decreasing the chance that the database integrity could be compromised due to tedious maintenance procedures.

  7. An Introduction to Database Normalization - Preliminary Definitions Terminology in Normalization: • Entity: The word ‘entity’ as it relates to databases can simply be defined as the general name for the information that is to be stored within a single table. • Example: for storing information about the school’s students, then ‘student’ would be the entity. • The student entity would likely be composed of several pieces of information, for example: • student identification number, name, and email address. These pieces of information are better known as attributes.

  8. Primary Key • A primary key uniquely identifies a row of data found within a table. • Referring to the school system, the student identification number would be the primary key for the student table since an ID would uniquely identify each student. • Note that a primary key might not necessarily correspond to one specific attribute. In fact, it could be the result of a combination of several components of the entity. • For example, while a location could not be a primary key for a class, since there might be several classes held there throughout the day, the combined time and location would make a satisfactory primary key, since no two classes could be held at the same time in the same location. When multiple attributes are used to derive a primary key, this key is known as a concatenated primary key.

  9. Relationship • Understanding of the various relationships both between the data items forming the various entities and between the entities themselves forms the crux of database normalization. • There are three types of data relationships that you should be aware of:

  10. Types of Relationships • one-to-one (1:1) - A one-to-one relationship signifies that each instance of a given entity relates to exactly one instance of another entity. For example, each student would have exactly one grade record, and each grade record would be specific to one student.one-to-many (1:M) - A one-to-many relationship signifies that each instance of a given entity relates to one or more instances of another entity. For example, one professor entity could be found teaching several classes, and each class could in turn be mapped to one professor.many-to-many (M:N) - A many-to-many relationship signifies that many instances of a given entity relate to many instances of another entity. To illustrate, a schedule could be comprised of many classes, and a class could be found within many schedules.

  11. Foreign Key and ERD • Foreign key: A foreign key forms the basis of a 1:M relationship between two tables. The foreign key can be found within the M table, and maps to the primary key found in the 1 table. To illustrate, the primary key in the professor table (probably a unique identification number) would be introduced as the foreign key within the classes entity, since it would be necessary to map a particular professor to several classes.Entity-relationship diagram (ERD): An ERD is essentially a graphical representation of the database structure. These diagrams, regardless of whether they are built using the latest design software or scrawled on a napkin with a crayon, are immensely useful towards attaining a better understanding of the dynamics of the various database relationships.

  12. Why Normalize? • Essentially, table optimization is accomplished through the elimination of all instances of data redundancy and unforeseen scaleability issues.

  13. Data Redundancy • Redundancy is attained when the same data values are stored more than once in a table, or when the same values are stored in more than one table. • To prevent redundancy in Database Tables, database normalization should be done to prevent redundancy and any other problems that might affect the performance of the database. • One of the biggest disadvantages of data redundancy is that it increases the size of the database unnecessarily. Also data redundancy might cause the same result to be returned as multiple search results when searching the database causing confusion and clutter in results.

  14. Avoiding Redundancy

  15. Analysis • Basically the table is a mapping of various students to the classes found within their schedule. • Issues: • Assuming that the only intention of this table is to create student-class mappings, then there really is no need to repeatedly store the class time and professor ID. • if there are 30 students to a class, then the class information would be repeated 30 times over!

  16. Why avoid Redundancy? • Redundancy introduces the possibility for error. • the name of the class found in the final row in the table (Matj 148). • Given the name of the class found in the first row, chances are that Matj 148 should actually be Math 148! • While this error is easily identifiable when just four rows are present in the table, imagine finding this error within the rows representing the 60,000 enrolled students

  17. Database Normalization - The Three Normal Forms • The process towards database normalization progressing through a series of steps, typically known as Normal Forms.

  18. First Normal Form • Converting a database to the first normal form is rather simple. • This first rule calls for the elimination of repeating groups of data through the creation of separate tables of related data. • Obviously, the original table contains several sets of repeating groups of data, namely classID, className, classTime, classLocation, professorID, professorName. Each attribute is repeated three times, allowing for each student to take three classes. • However, what if the student takes more than three classes? This, and other restrictions on this table should be obvious.

  19. Breaking bigger tables down into several smaller tables. The first table contains solely student information (Student):

  20. The second table contains solely class information (Class):

  21. The third table contains solely professor information (Professor):

  22. Second Normal form • Once you have separated the data into their respective tables, you can begin concentrating upon the rule of Second Normal Form- • -the elimination of redundant data. Referring back to the Class table, typical data stored within might look like:

  23. Second Normal Form

  24. While this table structure is certainly improved over the original, notice that there is still room for improvement. • In this case, the className attribute is being repeated. With 60,000 students stored in this table, performing an update to reflect a recent change in a course name could be somewhat of a problem. Therefore: • create a separate table that contains classID to className mappings (ClassIdentity):

  25. Class Identity

  26. The updated Class table would then be simply:

  27. Third Normal Form • Continuing on the quest for complete normalization of the school system database, the next step in the process would be to satisfy the rule of the Third Normal Form. • This rule seeks to eliminate all attributes from a table that are not directly dependent upon the primary key. In the case of the Student table, the college and college Location attributes are less dependent upon the student ID than they are on the major attribute. Therefore, we’ll create a new table that relates the major, college and college Location information:

  28. Third Normal Form

  29. The revised Student table would then look like:

  30. Some other Database Terms… • Data Mining • Data Matching • Distributed Databases • Boolean Operators • SQL Servers

  31. Thus Normalization is a systematic way of ensuring that a database structure is suitable for general-purpose querying and free of certain undesirable characteristics—insertion, update, and deletion anomalies—that could lead to a loss of data integrity.

  32. Data Mining and Data matching • Data mining refers to the process of analysing data in order to determine patterns and their relationships. • Data-matching involves bringing together data from different sources and comparing it. • Data-matching poses a particular threat to personal privacy because it involves analysing information about large numbers of people without prior cause for suspicion.

  33. Distributed Databases • A distributed database is a database in which portions of the database are stored on multiple computers within a network. Users have access to the portion of the database at their location so that they can access the data relevant to their tasks without interfering with the work of others.

  34. DDBMS • A centralized distributed database management system (DDBMS) manages the database as if it were all stored on the same computer. The DDBMS synchronizes all the data periodically and, in cases where multiple users must access the same data, ensures that updates and deletes performed on the data at one location will be automatically reflected in the data stored elsewhere

  35. Boolean operators • Boolean operators are used in programming • The main boolean operators are AND, OR, NOT, and XOR (exclusive or). • The words AND, OR, and NOT used to combine search terms when searching a database for information. • are called "logical operators" and are used to combine search terms to either broaden or narrow the retrieval results of searches

  36. SQL Servers • Structured Query Language • Microsoft SQL Server is a Relational Database produced by Microsoft.

  37. Questions?

More Related