Lecture 2 Notes
Lecture 2 Notes
Tables are the building blocks of relational databases. Showed table creation using Graphical and SQL
means.
Records/ tuple creation can be graphical, from a form to SQL and then into the database.
An entity is a row.
The first is entity integrity. Use the primary key to make sure each row is uniquely identifiable. Guarantee
that no duplicate or null values exist in the primary key columns to maintain data uniqueness.
The second is referential integrity. Establishing relationships between tables is done by using a foreign
key. Making sure the foreign key actually exists in the original table is referential integrity.
Then we do the understanding relationships slides. One to one, one to many or many to many
relationships can exist. Having a junction table for many to many relationships.
The third is domain integrity. Enforcing valid data entry. Uses constraints like check constraints to enforce
data range, format, or allowed values. This is column level stuff (domains are columns).
Now we will look at datatypes that we can use in databases and different DBMS have some custom data
types like money and small money.
Ensuring Data Consistency. ACID properties with transaction. Atomicity, Consistency, Isolation and
Durability.
Moving onto Normalization. It’s purpose is to reduce redundancy and we are going to investigate three
stages of it. 1NF is First Normal Form, 2NF is Second Normal Form, 3NF is Third Normal Form and so on.
Rules of 1NF. Each data item cannot be broken down any further. There are no columns with repeated or
similar data. Each row is unique (primary key). Each field has a unique name.
Rules of 2NF. Remove the partial dependencies. Only concerned with tables that have a composite
primary key. See example in slides.
Rules of 3NF. Remove transitive dependencies and remove any calculated values. See slide example.
Indexing for efficiency. Optimization technique for faster retrieval. Types and benefits.