SlideShare a Scribd company logo
1 of 12
Download to read offline
On SQL Managment studio
This lab is all about database normalization. Download, from DocShare, and run Week 6
Normalizing.sql to create the four databases, UNF (Unnormalized Form), FNF (First Normal
Form), SNF (Second Normal Form), and TNF (Third Norma Form) used in this lab. Each of the
following will be executed against all four databases. This will require a use and go statement
between each query. All four queries should be able to run at one time. The goal of this lab is to
show how the different normalization change how data is queried. Note: The same result set will
be returned from each database. This is a good check to see that each query is correct.
Write a select statement that returns the project code, project name, and project manager.
List each Employee’s name, department, and department name.
List employee by project.
List each employee, project name, hourly rate, and department name.
the database is
Use master
GO
--
-- Unnormalized Database
--
CREATE DATABASE UNF;
GO
USE UNF;
GO
CREATE TABLE Unnormalized
(
ProjectCode varchar(100),
ProjectName varchar(100),
ProjectManager varchar(255),
ProjectBudget Decimal(10,2),
EmployeeNumber varchar(10),
EmployeeName varchar(100),
DepartmentNumber varchar(10),
DepartmentName varchar(100),
HourlyRate Decimal(10,2)
);
INSERT INTO Unnormalized
(ProjectCode, ProjectName, ProjectManager, ProjectBudget, EmployeeNumber,
EmployeeName, DepartmentNumber, DepartmentName, HourlyRate)
VALUES ('PC010', 'Reservation System', 'Mr. Jones', 120500.00, 'S100', 'John', 'D03',
'Database', 21.00)
INSERT INTO Unnormalized
(ProjectCode, ProjectName, ProjectManager, ProjectBudget, EmployeeNumber,
EmployeeName, DepartmentNumber, DepartmentName, HourlyRate)
VALUES ('PC010', 'Reservation System', 'Mr. Jones', 120500.00, 'S101', 'George',
'D02', 'Testing', 16.50)
INSERT INTO Unnormalized
(ProjectCode, ProjectName, ProjectManager, ProjectBudget, EmployeeNumber,
EmployeeName, DepartmentNumber, DepartmentName, HourlyRate)
VALUES ('PC010', 'Reservation System', 'Mr. Jones', 120500.00, 'S102', 'Bob', 'D01',
'IT', 22.00)
INSERT INTO Unnormalized
(ProjectCode, ProjectName, ProjectManager, ProjectBudget, EmployeeNumber,
EmployeeName, DepartmentNumber, DepartmentName, HourlyRate)
VALUES ('PC011', 'HR System', 'Mrs. Smith', 500500.00, 'S103', 'Jack', 'D03',
'Database', 18.50)
INSERT INTO Unnormalized
(ProjectCode, ProjectName, ProjectManager, ProjectBudget, EmployeeNumber,
EmployeeName, DepartmentNumber, DepartmentName, HourlyRate)
VALUES ('PC011', 'HR System', 'Mrs. Smith', 500500.00, 'S104', 'Jane', 'D02',
'Testing', 17.00)
INSERT INTO Unnormalized
(ProjectCode, ProjectName, ProjectManager, ProjectBudget, EmployeeNumber,
EmployeeName, DepartmentNumber, DepartmentName, HourlyRate)
VALUES ('PC011', 'HR System', 'Mrs. Smith', 500500.00, 'S315', 'Dave', 'D01', 'IT',
23.50)
INSERT INTO Unnormalized
(ProjectCode, ProjectName, ProjectManager, ProjectBudget, EmployeeNumber,
EmployeeName, DepartmentNumber, DepartmentName, HourlyRate)
VALUES ('PC012', 'Attendance System', 'Mr. Doe', 710700.00, 'S137', 'Sam', 'D03',
'Database', 21.50)
INSERT INTO Unnormalized
(ProjectCode, ProjectName, ProjectManager, ProjectBudget, EmployeeNumber,
EmployeeName, DepartmentNumber, DepartmentName, HourlyRate)
VALUES ('PC012', 'Attendance System', 'Mr. Doe', 710700.00, 'S218', 'Neil', 'D02',
'Testing', 15.50)
INSERT INTO Unnormalized
(ProjectCode, ProjectName, ProjectManager, ProjectBudget, EmployeeNumber,
EmployeeName, DepartmentNumber, DepartmentName, HourlyRate)
VALUES ('PC012', 'Attendance System', 'Mr. Doe', 710700.00, 'S109', 'Hope', 'D01',
'IT', 20.50)
GO
--
-- First Normal Form
--
-- 1 - Separate the repeating fields into new database tables along with the key from
-- unnormalized database table.
--
-- 2 - The primary key of new database tables may be a composite key
--
CREATE DATABASE FNF;
GO
USE FNF;
GO
CREATE TABLE ProjectInfo
(
ProjectCode varchar(100),
ProjectName varchar(100),
ProjectManager varchar(255),
ProjectBudget Decimal(10,2)
PRIMARY KEY (ProjectCode)
);
CREATE TABLE ProjectStaff
(
ProjectCode varchar(100),
EmployeeNumber varchar(10),
EmployeeName varchar(100),
DepartmentNumber varchar(10),
DepartmentName varchar(100),
HourlyRate Decimal(10,2)
PRIMARY KEY (ProjectCode, EmployeeNumber)
FOREIGN KEY (ProjectCode) REFERENCES ProjectInfo
);
GO
INSERT INTO ProjectInfo
(ProjectCode, ProjectName, ProjectManager, ProjectBudget)
VALUES ('PC010', 'Reservation System', 'Mr. Jones', 120500.00);
INSERT INTO ProjectInfo
(ProjectCode, ProjectName, ProjectManager, ProjectBudget)
VALUES ('PC011', 'HR System', 'Mrs. Smith', 500500.00);
INSERT INTO ProjectInfo
(ProjectCode, ProjectName, ProjectManager, ProjectBudget)
VALUES ('PC012', 'Attendance System', 'Mr. Doe', 710700.00);
INSERT INTO ProjectStaff
(ProjectCode, EmployeeNumber, EmployeeName, DepartmentNumber, DepartmentName,
HourlyRate)
VALUES ('PC010', 'S100', 'John', 'D03', 'Database', 21.00);
INSERT INTO ProjectStaff
(ProjectCode, EmployeeNumber, EmployeeName, DepartmentNumber, DepartmentName,
HourlyRate)
VALUES ('PC010', 'S101', 'George', 'D02', 'Testing', 16.50);
INSERT INTO ProjectStaff
(ProjectCode, EmployeeNumber, EmployeeName, DepartmentNumber, DepartmentName,
HourlyRate)
VALUES ('PC010', 'S102', 'Bob', 'D01', 'IT', 22.00);
INSERT INTO ProjectStaff
(ProjectCode, EmployeeNumber, EmployeeName, DepartmentNumber, DepartmentName,
HourlyRate)
VALUES ('PC011', 'S103', 'Jack', 'D03', 'Database', 18.50);
INSERT INTO ProjectStaff
(ProjectCode, EmployeeNumber, EmployeeName, DepartmentNumber, DepartmentName,
HourlyRate)
VALUES ('PC011', 'S104', 'Jane', 'D02', 'Testing', 17.00);
INSERT INTO ProjectStaff
(ProjectCode, EmployeeNumber, EmployeeName, DepartmentNumber, DepartmentName,
HourlyRate)
VALUES ('PC011', 'S315', 'Dave', 'D01', 'IT', 23.50);
INSERT INTO ProjectStaff
(ProjectCode, EmployeeNumber, EmployeeName, DepartmentNumber, DepartmentName,
HourlyRate)
VALUES ('PC012', 'S137', 'Sam', 'D03', 'Database', 21.50);
INSERT INTO ProjectStaff
(ProjectCode, EmployeeNumber, EmployeeName, DepartmentNumber, DepartmentName,
HourlyRate)
VALUES ('PC012', 'S218', 'Neil', 'D02', 'Testing', 15.50);
INSERT INTO ProjectStaff
(ProjectCode, EmployeeNumber, EmployeeName, DepartmentNumber, DepartmentName,
HourlyRate)
VALUES ('PC012', 'S109', 'Hope', 'D01', 'IT', 20.50);
GO
--
-- Second Normal Form
--
-- 1 - First Normal Form Plus:
--
-- 2 - Remove the partial dependencies(A type of functional dependency where a field
-- is only functionally dependent on the part of primary key) of any non-key field.
--
-- 3 - If field B depends on field A and vice versa. Also for a given value of B, we have
-- only one possible value of A and vice versa, Then we put the field B in to new
-- database table where B will be primary key and also marked as foreign key in
-- parent table.
--
CREATE DATABASE SNF;
GO
USE SNF;
GO
CREATE TABLE ProjectInfo
(
ProjectCode varchar(100),
ProjectName varchar(100),
ProjectManager varchar(255),
ProjectBudget Decimal(10,2)
PRIMARY KEY (ProjectCode)
);
CREATE TABLE EmployeeInfo
(
EmployeeNumber varchar(10),
EmployeeName varchar(100),
DepartmentNumber varchar(10),
DepartmentName varchar(100)
PRIMARY KEY (EmployeeNumber)
);
CREATE TABLE ProjectRates
(
ProjectCode varchar(100),
EmployeeNumber varchar(10),
HourlyRate Decimal(10,2)
PRIMARY KEY (ProjectCode, EmployeeNumber)
FOREIGN KEY (ProjectCode) REFERENCES ProjectInfo,
FOREIGN KEY (EmployeeNumber) REFERENCES EmployeeInfo
);
GO
INSERT INTO ProjectInfo
(ProjectCode, ProjectName, ProjectManager, ProjectBudget)
VALUES ('PC010', 'Reservation System', 'Mr. Jones', 120500.00);
INSERT INTO ProjectInfo
(ProjectCode, ProjectName, ProjectManager, ProjectBudget)
VALUES ('PC011', 'HR System', 'Mrs. Smith', 500500.00);
INSERT INTO ProjectInfo
(ProjectCode, ProjectName, ProjectManager, ProjectBudget)
VALUES ('PC012', 'Attendance System', 'Mr. Doe', 710700.00);
INSERT INTO EmployeeInfo
(EmployeeNumber, EmployeeName, DepartmentNumber, DepartmentName)
VALUES ('S100', 'John', 'D03', 'Database');
INSERT INTO EmployeeInfo
(EmployeeNumber, EmployeeName, DepartmentNumber, DepartmentName)
VALUES ('S101', 'George', 'D02', 'Testing');
INSERT INTO EmployeeInfo
(EmployeeNumber, EmployeeName, DepartmentNumber, DepartmentName)
VALUES ('S102', 'Bob', 'D01', 'IT');
INSERT INTO EmployeeInfo
(EmployeeNumber, EmployeeName, DepartmentNumber, DepartmentName)
VALUES ('S103', 'Jack', 'D03', 'Database');
INSERT INTO EmployeeInfo
(EmployeeNumber, EmployeeName, DepartmentNumber, DepartmentName)
VALUES ('S104', 'Jane', 'D02', 'Testing');
INSERT INTO EmployeeInfo
(EmployeeNumber, EmployeeName, DepartmentNumber, DepartmentName)
VALUES ('S315', 'Dave', 'D01', 'IT');
INSERT INTO EmployeeInfo
(EmployeeNumber, EmployeeName, DepartmentNumber, DepartmentName)
VALUES ('S137', 'Sam', 'D03', 'Database');
INSERT INTO EmployeeInfo
(EmployeeNumber, EmployeeName, DepartmentNumber, DepartmentName)
VALUES ('S218', 'Neil', 'D02', 'Testing');
INSERT INTO EmployeeInfo
(EmployeeNumber, EmployeeName, DepartmentNumber, DepartmentName)
VALUES ('S109', 'Hope', 'D01', 'IT');
INSERT INTO ProjectRates
(ProjectCode, EmployeeNumber, HourlyRate)
VALUES ('PC010', 'S100', 21.00);
INSERT INTO ProjectRates
(ProjectCode, EmployeeNumber, HourlyRate)
VALUES ('PC010', 'S101', 16.50);
INSERT INTO ProjectRates
(ProjectCode, EmployeeNumber, HourlyRate)
VALUES ('PC010', 'S102', 22.00);
INSERT INTO ProjectRates
(ProjectCode, EmployeeNumber, HourlyRate)
VALUES ('PC011', 'S103', 18.50);
INSERT INTO ProjectRates
(ProjectCode, EmployeeNumber, HourlyRate)
VALUES ('PC011', 'S104', 17.00);
INSERT INTO ProjectRates
(ProjectCode, EmployeeNumber, HourlyRate)
VALUES ('PC011', 'S315', 23.50);
INSERT INTO ProjectRates
(ProjectCode, EmployeeNumber, HourlyRate)
VALUES ('PC012', 'S137', 21.50);
INSERT INTO ProjectRates
(ProjectCode, EmployeeNumber, HourlyRate)
VALUES ('PC012', 'S218', 15.50);
INSERT INTO ProjectRates
(ProjectCode, EmployeeNumber, HourlyRate)
VALUES ('PC012', 'S109', 20.50);
GO
--
-- Third Normal Form
--
-- 1 - Second Normal Form Plus:
--
-- 2 - Remove the transitive dependecies(A type of functional dependency where a field
-- is functionally dependent on the Field that is not the primary key.Hence
-- its value is determined, indirectly by the primary key )
--
-- 3 - Make separate table for transitive dependent Field.
--
CREATE DATABASE TNF;
GO
USE TNF;
GO
CREATE TABLE ProjectInfo
(
ProjectCode varchar(100),
ProjectName varchar(100),
ProjectManager varchar(255),
ProjectBudget Decimal(10,2)
PRIMARY KEY (ProjectCode)
);
CREATE TABLE DepartmentInfo
(
DepartmentNumber varchar(10),
DepartmentName varchar(100),
PRIMARY KEY (DepartmentNumber)
);
CREATE TABLE EmployeeInfo
(
EmployeeNumber varchar(10),
EmployeeName varchar(100),
DepartmentNumber varchar(10)
PRIMARY KEY (EmployeeNumber)
FOREIGN KEY REFERENCES DepartmentInfo(DepartmentNumber)
);
CREATE TABLE ProjectRates
(
ProjectCode varchar(100),
EmployeeNumber varchar(10),
HourlyRate Decimal(10,2)
PRIMARY KEY (ProjectCode, EmployeeNumber)
FOREIGN KEY (ProjectCode) REFERENCES ProjectInfo,
FOREIGN KEY (EmployeeNumber) REFERENCES EmployeeInfo
);
GO
INSERT INTO ProjectInfo
(ProjectCode, ProjectName, ProjectManager, ProjectBudget)
VALUES ('PC010', 'Reservation System', 'Mr. Jones', 120500.00);
INSERT INTO ProjectInfo
(ProjectCode, ProjectName, ProjectManager, ProjectBudget)
VALUES ('PC011', 'HR System', 'Mrs. Smith', 500500.00);
INSERT INTO ProjectInfo
(ProjectCode, ProjectName, ProjectManager, ProjectBudget)
VALUES ('PC012', 'Attendance System', 'Mr. Doe', 710700.00);
INSERT INTO DepartmentInfo
(DepartmentNumber, DepartmentName)
VALUES ('D03', 'Database');
INSERT INTO DepartmentInfo
(DepartmentNumber, DepartmentName)
VALUES ('D02', 'Testing');
INSERT INTO DepartmentInfo
(DepartmentNumber, DepartmentName)
VALUES ('D01', 'IT');
INSERT INTO EmployeeInfo
(EmployeeNumber, EmployeeName, DepartmentNumber)
VALUES ('S100', 'John', 'D03');
INSERT INTO EmployeeInfo
(EmployeeNumber, EmployeeName, DepartmentNumber)
VALUES ('S101', 'George', 'D02');
INSERT INTO EmployeeInfo
(EmployeeNumber, EmployeeName, DepartmentNumber)
VALUES ('S102', 'Bob', 'D01');
INSERT INTO EmployeeInfo
(EmployeeNumber, EmployeeName, DepartmentNumber)
VALUES ('S103', 'Jack', 'D03');
INSERT INTO EmployeeInfo
(EmployeeNumber, EmployeeName, DepartmentNumber)
VALUES ('S104', 'Jane', 'D02');
INSERT INTO EmployeeInfo
(EmployeeNumber, EmployeeName, DepartmentNumber)
VALUES ('S315', 'Dave', 'D01');
INSERT INTO EmployeeInfo
(EmployeeNumber, EmployeeName, DepartmentNumber)
VALUES ('S137', 'Sam', 'D03');
INSERT INTO EmployeeInfo
(EmployeeNumber, EmployeeName, DepartmentNumber)
VALUES ('S218', 'Neil', 'D02');
INSERT INTO EmployeeInfo
(EmployeeNumber, EmployeeName, DepartmentNumber)
VALUES ('S109', 'Hope', 'D01');
INSERT INTO ProjectRates
(ProjectCode, EmployeeNumber, HourlyRate)
VALUES ('PC010', 'S100', 21.00);
INSERT INTO ProjectRates
(ProjectCode, EmployeeNumber, HourlyRate)
VALUES ('PC010', 'S101', 16.50);
INSERT INTO ProjectRates
(ProjectCode, EmployeeNumber, HourlyRate)
VALUES ('PC010', 'S102', 22.00);
INSERT INTO ProjectRates
(ProjectCode, EmployeeNumber, HourlyRate)
VALUES ('PC011', 'S103', 18.50);
INSERT INTO ProjectRates
(ProjectCode, EmployeeNumber, HourlyRate)
VALUES ('PC011', 'S104', 17.00);
INSERT INTO ProjectRates
(ProjectCode, EmployeeNumber, HourlyRate)
VALUES ('PC011', 'S315', 23.50);
INSERT INTO ProjectRates
(ProjectCode, EmployeeNumber, HourlyRate)
VALUES ('PC012', 'S137', 21.50);
INSERT INTO ProjectRates
(ProjectCode, EmployeeNumber, HourlyRate)
VALUES ('PC012', 'S218', 15.50);
INSERT INTO ProjectRates
(ProjectCode, EmployeeNumber, HourlyRate)
VALUES ('PC012', 'S109', 20.50);
Solution
here are 12 queries for the database. whenever you find all columns in a single table, you just
fetch it. Otherwise you have to join the 2 tables based on the matching common key... like in our
example ProjectCode or EmployeeNumber. Also using table aliases its convinient to write
queries in more readable and short form.
=========================
for unnormalized form
select ProjectCode,ProjectName,ProjectManager from Unnormalized;
select Employeename,DepartmentNumber,DepartmentName from Unnormalized;
select ProjectCode ,Employeename from Unnormalized order by ProjectCode;
select ProjectName ,EmployeeName,HourlyRate, DepartmentName from Unnormalized;
===========================================
for 1st normal form
select ProjectCode,ProjectName,ProjectManager from ProjectInfo;
select Employeename,DepartmentNumber,DepartmentName from ProjectStaff;
select ProjectCode ,Employeename from ProjectStaff;
select p.ProjectName ,s.EmployeeName,s.HourlyRate, s.DepartmentName
from ProjectStaff s JOIN ProjectInfo p
using (ProjectCode);
========================================
for 2nd normal form
select ProjectCode,ProjectName,ProjectManager from ProjectInfo;
select Employeename,DepartmentNumber,DepartmentName from EmployeeInfo;
select r.ProjectCode ,e.EmployeeName
from ProjectRates r JOIN EmployeeInfo e
using (EmployeeNumber);
SELECT p.ProjectName,e.EmployeeName,e.DepartmentName,r.HourlyRate
FROM
ProjectRates r
INNER JOIN
EmployeeInfo e on r.EmployeeNumber = e.EmployeeNumber
LEFT JOIN
ProjectInfo p on r.ProjectCode = p.ProjectCode

More Related Content

Similar to On SQL Managment studioThis lab is all about database normalizatio.pdf

Running Intelligent Applications inside a Database: Deep Learning with Python...
Running Intelligent Applications inside a Database: Deep Learning with Python...Running Intelligent Applications inside a Database: Deep Learning with Python...
Running Intelligent Applications inside a Database: Deep Learning with Python...Miguel González-Fierro
 
Complex Queries using MYSQL00123211.pptx
Complex Queries using MYSQL00123211.pptxComplex Queries using MYSQL00123211.pptx
Complex Queries using MYSQL00123211.pptxmetriohanzel
 
Beyond PHP - It's not (just) about the code
Beyond PHP - It's not (just) about the codeBeyond PHP - It's not (just) about the code
Beyond PHP - It's not (just) about the codeWim Godden
 
SQL FILE FROM MOODLEUSE [master]GO Object Databa.pdf
SQL FILE FROM MOODLEUSE [master]GO Object Databa.pdfSQL FILE FROM MOODLEUSE [master]GO Object Databa.pdf
SQL FILE FROM MOODLEUSE [master]GO Object Databa.pdfarrowit1
 
Uncovering SQL Server query problems with execution plans - Tony Davis
Uncovering SQL Server query problems with execution plans - Tony DavisUncovering SQL Server query problems with execution plans - Tony Davis
Uncovering SQL Server query problems with execution plans - Tony DavisRed Gate Software
 
Introduction to SQL Antipatterns
Introduction to SQL AntipatternsIntroduction to SQL Antipatterns
Introduction to SQL AntipatternsKrishnakumar S
 
When to NoSQL and when to know SQL
When to NoSQL and when to know SQLWhen to NoSQL and when to know SQL
When to NoSQL and when to know SQLSimon Elliston Ball
 
Advanced app building with PowerApps expressions and rules
Advanced app building with PowerApps expressions and rulesAdvanced app building with PowerApps expressions and rules
Advanced app building with PowerApps expressions and rulesMicrosoft Tech Community
 
IFESFinal58
IFESFinal58IFESFinal58
IFESFinal58anish h
 
Data Exploration with Apache Drill: Day 2
Data Exploration with Apache Drill: Day 2Data Exploration with Apache Drill: Day 2
Data Exploration with Apache Drill: Day 2Charles Givre
 
Kevin Bengtson Portfolio
Kevin Bengtson PortfolioKevin Bengtson Portfolio
Kevin Bengtson PortfolioKbengt521
 
Webinar: Transitioning from SQL to MongoDB
Webinar: Transitioning from SQL to MongoDBWebinar: Transitioning from SQL to MongoDB
Webinar: Transitioning from SQL to MongoDBMongoDB
 
Killing ETL with Apache Drill
Killing ETL with Apache DrillKilling ETL with Apache Drill
Killing ETL with Apache DrillCharles Givre
 
Fast REST APIs Development with MongoDB
Fast REST APIs Development with MongoDBFast REST APIs Development with MongoDB
Fast REST APIs Development with MongoDBMongoDB
 
Sql server ___________session_18(stored procedures)
Sql server  ___________session_18(stored procedures)Sql server  ___________session_18(stored procedures)
Sql server ___________session_18(stored procedures)Ehtisham Ali
 
Chris Mc Glothen Sql Portfolio
Chris Mc Glothen Sql PortfolioChris Mc Glothen Sql Portfolio
Chris Mc Glothen Sql Portfolioclmcglothen
 
M.TECH 1ST SEM COMPUTER SCIENCE ADBMS LAB PROGRAMS
M.TECH 1ST SEM COMPUTER SCIENCE ADBMS LAB PROGRAMSM.TECH 1ST SEM COMPUTER SCIENCE ADBMS LAB PROGRAMS
M.TECH 1ST SEM COMPUTER SCIENCE ADBMS LAB PROGRAMSSupriya Radhakrishna
 

Similar to On SQL Managment studioThis lab is all about database normalizatio.pdf (20)

Running Intelligent Applications inside a Database: Deep Learning with Python...
Running Intelligent Applications inside a Database: Deep Learning with Python...Running Intelligent Applications inside a Database: Deep Learning with Python...
Running Intelligent Applications inside a Database: Deep Learning with Python...
 
Complex Queries using MYSQL00123211.pptx
Complex Queries using MYSQL00123211.pptxComplex Queries using MYSQL00123211.pptx
Complex Queries using MYSQL00123211.pptx
 
Beyond PHP - It's not (just) about the code
Beyond PHP - It's not (just) about the codeBeyond PHP - It's not (just) about the code
Beyond PHP - It's not (just) about the code
 
SQL FILE FROM MOODLEUSE [master]GO Object Databa.pdf
SQL FILE FROM MOODLEUSE [master]GO Object Databa.pdfSQL FILE FROM MOODLEUSE [master]GO Object Databa.pdf
SQL FILE FROM MOODLEUSE [master]GO Object Databa.pdf
 
Uncovering SQL Server query problems with execution plans - Tony Davis
Uncovering SQL Server query problems with execution plans - Tony DavisUncovering SQL Server query problems with execution plans - Tony Davis
Uncovering SQL Server query problems with execution plans - Tony Davis
 
Introduction to SQL Antipatterns
Introduction to SQL AntipatternsIntroduction to SQL Antipatterns
Introduction to SQL Antipatterns
 
When to NoSQL and when to know SQL
When to NoSQL and when to know SQLWhen to NoSQL and when to know SQL
When to NoSQL and when to know SQL
 
Advanced app building with PowerApps expressions and rules
Advanced app building with PowerApps expressions and rulesAdvanced app building with PowerApps expressions and rules
Advanced app building with PowerApps expressions and rules
 
IFESFinal58
IFESFinal58IFESFinal58
IFESFinal58
 
Data Exploration with Apache Drill: Day 2
Data Exploration with Apache Drill: Day 2Data Exploration with Apache Drill: Day 2
Data Exploration with Apache Drill: Day 2
 
Kevin Bengtson Portfolio
Kevin Bengtson PortfolioKevin Bengtson Portfolio
Kevin Bengtson Portfolio
 
Webinar: Transitioning from SQL to MongoDB
Webinar: Transitioning from SQL to MongoDBWebinar: Transitioning from SQL to MongoDB
Webinar: Transitioning from SQL to MongoDB
 
Killing ETL with Apache Drill
Killing ETL with Apache DrillKilling ETL with Apache Drill
Killing ETL with Apache Drill
 
Fast REST APIs Development with MongoDB
Fast REST APIs Development with MongoDBFast REST APIs Development with MongoDB
Fast REST APIs Development with MongoDB
 
My Portfolio
My PortfolioMy Portfolio
My Portfolio
 
My Portfolio
My PortfolioMy Portfolio
My Portfolio
 
Sql server ___________session_18(stored procedures)
Sql server  ___________session_18(stored procedures)Sql server  ___________session_18(stored procedures)
Sql server ___________session_18(stored procedures)
 
Chris Mc Glothen Sql Portfolio
Chris Mc Glothen Sql PortfolioChris Mc Glothen Sql Portfolio
Chris Mc Glothen Sql Portfolio
 
70433 Dumps DB
70433 Dumps DB70433 Dumps DB
70433 Dumps DB
 
M.TECH 1ST SEM COMPUTER SCIENCE ADBMS LAB PROGRAMS
M.TECH 1ST SEM COMPUTER SCIENCE ADBMS LAB PROGRAMSM.TECH 1ST SEM COMPUTER SCIENCE ADBMS LAB PROGRAMS
M.TECH 1ST SEM COMPUTER SCIENCE ADBMS LAB PROGRAMS
 

More from infomalad

Operating systems have to balance the conflicting goals of convenien.pdf
Operating systems have to balance the conflicting goals of convenien.pdfOperating systems have to balance the conflicting goals of convenien.pdf
Operating systems have to balance the conflicting goals of convenien.pdfinfomalad
 
PARTI PHILOSOPHY AND CONCEPTS FLEXIBLE BENEFITS SYSTEM IMPLEMENTATION.pdf
PARTI PHILOSOPHY AND CONCEPTS FLEXIBLE BENEFITS SYSTEM IMPLEMENTATION.pdfPARTI PHILOSOPHY AND CONCEPTS FLEXIBLE BENEFITS SYSTEM IMPLEMENTATION.pdf
PARTI PHILOSOPHY AND CONCEPTS FLEXIBLE BENEFITS SYSTEM IMPLEMENTATION.pdfinfomalad
 
Maria, an experienced shipping clerk, can fill a certain order in 11.pdf
Maria, an experienced shipping clerk, can fill a certain order in 11.pdfMaria, an experienced shipping clerk, can fill a certain order in 11.pdf
Maria, an experienced shipping clerk, can fill a certain order in 11.pdfinfomalad
 
List the problems that can be efficiently solved by Evolutionary P.pdf
List the problems that can be efficiently solved by Evolutionary P.pdfList the problems that can be efficiently solved by Evolutionary P.pdf
List the problems that can be efficiently solved by Evolutionary P.pdfinfomalad
 
Implement the insertFirst member function of the LinkedList class . .pdf
Implement the insertFirst member function of the LinkedList class . .pdfImplement the insertFirst member function of the LinkedList class . .pdf
Implement the insertFirst member function of the LinkedList class . .pdfinfomalad
 
I need to get a 910 in order to pass this and I have 40 mins from n.pdf
I need to get a 910 in order to pass this and I have 40 mins from n.pdfI need to get a 910 in order to pass this and I have 40 mins from n.pdf
I need to get a 910 in order to pass this and I have 40 mins from n.pdfinfomalad
 
If related parties complete a qualified like-kind exchange, how long.pdf
If related parties complete a qualified like-kind exchange, how long.pdfIf related parties complete a qualified like-kind exchange, how long.pdf
If related parties complete a qualified like-kind exchange, how long.pdfinfomalad
 
How innovative offerings gain acceptance within market segmentsH.pdf
How innovative offerings gain acceptance within market segmentsH.pdfHow innovative offerings gain acceptance within market segmentsH.pdf
How innovative offerings gain acceptance within market segmentsH.pdfinfomalad
 
How does an organization socialize an individualHow ATM(automated.pdf
How does an organization socialize an individualHow ATM(automated.pdfHow does an organization socialize an individualHow ATM(automated.pdf
How does an organization socialize an individualHow ATM(automated.pdfinfomalad
 
Homework Develop a strategylies) to get a house. Consider possible h.pdf
Homework Develop a strategylies) to get a house. Consider possible h.pdfHomework Develop a strategylies) to get a house. Consider possible h.pdf
Homework Develop a strategylies) to get a house. Consider possible h.pdfinfomalad
 
Given a definition of a group Given a definition of a group.pdf
Given a definition of a group Given a definition of a group.pdfGiven a definition of a group Given a definition of a group.pdf
Given a definition of a group Given a definition of a group.pdfinfomalad
 
Given the indexed collection of denumerable sets A_i with i N, prov.pdf
Given the indexed collection of denumerable sets A_i with i  N,  prov.pdfGiven the indexed collection of denumerable sets A_i with i  N,  prov.pdf
Given the indexed collection of denumerable sets A_i with i N, prov.pdfinfomalad
 
give an example of a successful progect thats ben done by a virtual .pdf
give an example of a successful progect thats ben done by a virtual .pdfgive an example of a successful progect thats ben done by a virtual .pdf
give an example of a successful progect thats ben done by a virtual .pdfinfomalad
 
File name a2.cppTaskFor this assignment, you are required to ei.pdf
File name a2.cppTaskFor this assignment, you are required to ei.pdfFile name a2.cppTaskFor this assignment, you are required to ei.pdf
File name a2.cppTaskFor this assignment, you are required to ei.pdfinfomalad
 
Explain in detail the DTE-DCE TransmissionSolutionData commun.pdf
Explain in detail the DTE-DCE TransmissionSolutionData commun.pdfExplain in detail the DTE-DCE TransmissionSolutionData commun.pdf
Explain in detail the DTE-DCE TransmissionSolutionData commun.pdfinfomalad
 
Find an example of a real project with a real project manager. The pr.pdf
Find an example of a real project with a real project manager. The pr.pdfFind an example of a real project with a real project manager. The pr.pdf
Find an example of a real project with a real project manager. The pr.pdfinfomalad
 
Discuss the importance of security and what elements need to be addr.pdf
Discuss the importance of security and what elements need to be addr.pdfDiscuss the importance of security and what elements need to be addr.pdf
Discuss the importance of security and what elements need to be addr.pdfinfomalad
 
Define financial engineering in terms of how to change the risk-retu.pdf
Define financial engineering in terms of how to change the risk-retu.pdfDefine financial engineering in terms of how to change the risk-retu.pdf
Define financial engineering in terms of how to change the risk-retu.pdfinfomalad
 
As a result of total quality management, organizational changes in t.pdf
As a result of total quality management, organizational changes in t.pdfAs a result of total quality management, organizational changes in t.pdf
As a result of total quality management, organizational changes in t.pdfinfomalad
 
Complete and balance the following redox equation. Show all work and.pdf
Complete and balance the following redox equation. Show all work and.pdfComplete and balance the following redox equation. Show all work and.pdf
Complete and balance the following redox equation. Show all work and.pdfinfomalad
 

More from infomalad (20)

Operating systems have to balance the conflicting goals of convenien.pdf
Operating systems have to balance the conflicting goals of convenien.pdfOperating systems have to balance the conflicting goals of convenien.pdf
Operating systems have to balance the conflicting goals of convenien.pdf
 
PARTI PHILOSOPHY AND CONCEPTS FLEXIBLE BENEFITS SYSTEM IMPLEMENTATION.pdf
PARTI PHILOSOPHY AND CONCEPTS FLEXIBLE BENEFITS SYSTEM IMPLEMENTATION.pdfPARTI PHILOSOPHY AND CONCEPTS FLEXIBLE BENEFITS SYSTEM IMPLEMENTATION.pdf
PARTI PHILOSOPHY AND CONCEPTS FLEXIBLE BENEFITS SYSTEM IMPLEMENTATION.pdf
 
Maria, an experienced shipping clerk, can fill a certain order in 11.pdf
Maria, an experienced shipping clerk, can fill a certain order in 11.pdfMaria, an experienced shipping clerk, can fill a certain order in 11.pdf
Maria, an experienced shipping clerk, can fill a certain order in 11.pdf
 
List the problems that can be efficiently solved by Evolutionary P.pdf
List the problems that can be efficiently solved by Evolutionary P.pdfList the problems that can be efficiently solved by Evolutionary P.pdf
List the problems that can be efficiently solved by Evolutionary P.pdf
 
Implement the insertFirst member function of the LinkedList class . .pdf
Implement the insertFirst member function of the LinkedList class . .pdfImplement the insertFirst member function of the LinkedList class . .pdf
Implement the insertFirst member function of the LinkedList class . .pdf
 
I need to get a 910 in order to pass this and I have 40 mins from n.pdf
I need to get a 910 in order to pass this and I have 40 mins from n.pdfI need to get a 910 in order to pass this and I have 40 mins from n.pdf
I need to get a 910 in order to pass this and I have 40 mins from n.pdf
 
If related parties complete a qualified like-kind exchange, how long.pdf
If related parties complete a qualified like-kind exchange, how long.pdfIf related parties complete a qualified like-kind exchange, how long.pdf
If related parties complete a qualified like-kind exchange, how long.pdf
 
How innovative offerings gain acceptance within market segmentsH.pdf
How innovative offerings gain acceptance within market segmentsH.pdfHow innovative offerings gain acceptance within market segmentsH.pdf
How innovative offerings gain acceptance within market segmentsH.pdf
 
How does an organization socialize an individualHow ATM(automated.pdf
How does an organization socialize an individualHow ATM(automated.pdfHow does an organization socialize an individualHow ATM(automated.pdf
How does an organization socialize an individualHow ATM(automated.pdf
 
Homework Develop a strategylies) to get a house. Consider possible h.pdf
Homework Develop a strategylies) to get a house. Consider possible h.pdfHomework Develop a strategylies) to get a house. Consider possible h.pdf
Homework Develop a strategylies) to get a house. Consider possible h.pdf
 
Given a definition of a group Given a definition of a group.pdf
Given a definition of a group Given a definition of a group.pdfGiven a definition of a group Given a definition of a group.pdf
Given a definition of a group Given a definition of a group.pdf
 
Given the indexed collection of denumerable sets A_i with i N, prov.pdf
Given the indexed collection of denumerable sets A_i with i  N,  prov.pdfGiven the indexed collection of denumerable sets A_i with i  N,  prov.pdf
Given the indexed collection of denumerable sets A_i with i N, prov.pdf
 
give an example of a successful progect thats ben done by a virtual .pdf
give an example of a successful progect thats ben done by a virtual .pdfgive an example of a successful progect thats ben done by a virtual .pdf
give an example of a successful progect thats ben done by a virtual .pdf
 
File name a2.cppTaskFor this assignment, you are required to ei.pdf
File name a2.cppTaskFor this assignment, you are required to ei.pdfFile name a2.cppTaskFor this assignment, you are required to ei.pdf
File name a2.cppTaskFor this assignment, you are required to ei.pdf
 
Explain in detail the DTE-DCE TransmissionSolutionData commun.pdf
Explain in detail the DTE-DCE TransmissionSolutionData commun.pdfExplain in detail the DTE-DCE TransmissionSolutionData commun.pdf
Explain in detail the DTE-DCE TransmissionSolutionData commun.pdf
 
Find an example of a real project with a real project manager. The pr.pdf
Find an example of a real project with a real project manager. The pr.pdfFind an example of a real project with a real project manager. The pr.pdf
Find an example of a real project with a real project manager. The pr.pdf
 
Discuss the importance of security and what elements need to be addr.pdf
Discuss the importance of security and what elements need to be addr.pdfDiscuss the importance of security and what elements need to be addr.pdf
Discuss the importance of security and what elements need to be addr.pdf
 
Define financial engineering in terms of how to change the risk-retu.pdf
Define financial engineering in terms of how to change the risk-retu.pdfDefine financial engineering in terms of how to change the risk-retu.pdf
Define financial engineering in terms of how to change the risk-retu.pdf
 
As a result of total quality management, organizational changes in t.pdf
As a result of total quality management, organizational changes in t.pdfAs a result of total quality management, organizational changes in t.pdf
As a result of total quality management, organizational changes in t.pdf
 
Complete and balance the following redox equation. Show all work and.pdf
Complete and balance the following redox equation. Show all work and.pdfComplete and balance the following redox equation. Show all work and.pdf
Complete and balance the following redox equation. Show all work and.pdf
 

Recently uploaded

BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...PsychoTech Services
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 

Recently uploaded (20)

BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 

On SQL Managment studioThis lab is all about database normalizatio.pdf

  • 1. On SQL Managment studio This lab is all about database normalization. Download, from DocShare, and run Week 6 Normalizing.sql to create the four databases, UNF (Unnormalized Form), FNF (First Normal Form), SNF (Second Normal Form), and TNF (Third Norma Form) used in this lab. Each of the following will be executed against all four databases. This will require a use and go statement between each query. All four queries should be able to run at one time. The goal of this lab is to show how the different normalization change how data is queried. Note: The same result set will be returned from each database. This is a good check to see that each query is correct. Write a select statement that returns the project code, project name, and project manager. List each Employee’s name, department, and department name. List employee by project. List each employee, project name, hourly rate, and department name. the database is Use master GO -- -- Unnormalized Database -- CREATE DATABASE UNF; GO USE UNF; GO CREATE TABLE Unnormalized ( ProjectCode varchar(100), ProjectName varchar(100), ProjectManager varchar(255), ProjectBudget Decimal(10,2), EmployeeNumber varchar(10), EmployeeName varchar(100), DepartmentNumber varchar(10), DepartmentName varchar(100), HourlyRate Decimal(10,2) );
  • 2. INSERT INTO Unnormalized (ProjectCode, ProjectName, ProjectManager, ProjectBudget, EmployeeNumber, EmployeeName, DepartmentNumber, DepartmentName, HourlyRate) VALUES ('PC010', 'Reservation System', 'Mr. Jones', 120500.00, 'S100', 'John', 'D03', 'Database', 21.00) INSERT INTO Unnormalized (ProjectCode, ProjectName, ProjectManager, ProjectBudget, EmployeeNumber, EmployeeName, DepartmentNumber, DepartmentName, HourlyRate) VALUES ('PC010', 'Reservation System', 'Mr. Jones', 120500.00, 'S101', 'George', 'D02', 'Testing', 16.50) INSERT INTO Unnormalized (ProjectCode, ProjectName, ProjectManager, ProjectBudget, EmployeeNumber, EmployeeName, DepartmentNumber, DepartmentName, HourlyRate) VALUES ('PC010', 'Reservation System', 'Mr. Jones', 120500.00, 'S102', 'Bob', 'D01', 'IT', 22.00) INSERT INTO Unnormalized (ProjectCode, ProjectName, ProjectManager, ProjectBudget, EmployeeNumber, EmployeeName, DepartmentNumber, DepartmentName, HourlyRate) VALUES ('PC011', 'HR System', 'Mrs. Smith', 500500.00, 'S103', 'Jack', 'D03', 'Database', 18.50) INSERT INTO Unnormalized (ProjectCode, ProjectName, ProjectManager, ProjectBudget, EmployeeNumber, EmployeeName, DepartmentNumber, DepartmentName, HourlyRate) VALUES ('PC011', 'HR System', 'Mrs. Smith', 500500.00, 'S104', 'Jane', 'D02', 'Testing', 17.00) INSERT INTO Unnormalized (ProjectCode, ProjectName, ProjectManager, ProjectBudget, EmployeeNumber, EmployeeName, DepartmentNumber, DepartmentName, HourlyRate) VALUES ('PC011', 'HR System', 'Mrs. Smith', 500500.00, 'S315', 'Dave', 'D01', 'IT', 23.50) INSERT INTO Unnormalized (ProjectCode, ProjectName, ProjectManager, ProjectBudget, EmployeeNumber, EmployeeName, DepartmentNumber, DepartmentName, HourlyRate) VALUES ('PC012', 'Attendance System', 'Mr. Doe', 710700.00, 'S137', 'Sam', 'D03', 'Database', 21.50) INSERT INTO Unnormalized
  • 3. (ProjectCode, ProjectName, ProjectManager, ProjectBudget, EmployeeNumber, EmployeeName, DepartmentNumber, DepartmentName, HourlyRate) VALUES ('PC012', 'Attendance System', 'Mr. Doe', 710700.00, 'S218', 'Neil', 'D02', 'Testing', 15.50) INSERT INTO Unnormalized (ProjectCode, ProjectName, ProjectManager, ProjectBudget, EmployeeNumber, EmployeeName, DepartmentNumber, DepartmentName, HourlyRate) VALUES ('PC012', 'Attendance System', 'Mr. Doe', 710700.00, 'S109', 'Hope', 'D01', 'IT', 20.50) GO -- -- First Normal Form -- -- 1 - Separate the repeating fields into new database tables along with the key from -- unnormalized database table. -- -- 2 - The primary key of new database tables may be a composite key -- CREATE DATABASE FNF; GO USE FNF; GO CREATE TABLE ProjectInfo ( ProjectCode varchar(100), ProjectName varchar(100), ProjectManager varchar(255), ProjectBudget Decimal(10,2) PRIMARY KEY (ProjectCode) ); CREATE TABLE ProjectStaff ( ProjectCode varchar(100), EmployeeNumber varchar(10), EmployeeName varchar(100), DepartmentNumber varchar(10),
  • 4. DepartmentName varchar(100), HourlyRate Decimal(10,2) PRIMARY KEY (ProjectCode, EmployeeNumber) FOREIGN KEY (ProjectCode) REFERENCES ProjectInfo ); GO INSERT INTO ProjectInfo (ProjectCode, ProjectName, ProjectManager, ProjectBudget) VALUES ('PC010', 'Reservation System', 'Mr. Jones', 120500.00); INSERT INTO ProjectInfo (ProjectCode, ProjectName, ProjectManager, ProjectBudget) VALUES ('PC011', 'HR System', 'Mrs. Smith', 500500.00); INSERT INTO ProjectInfo (ProjectCode, ProjectName, ProjectManager, ProjectBudget) VALUES ('PC012', 'Attendance System', 'Mr. Doe', 710700.00); INSERT INTO ProjectStaff (ProjectCode, EmployeeNumber, EmployeeName, DepartmentNumber, DepartmentName, HourlyRate) VALUES ('PC010', 'S100', 'John', 'D03', 'Database', 21.00); INSERT INTO ProjectStaff (ProjectCode, EmployeeNumber, EmployeeName, DepartmentNumber, DepartmentName, HourlyRate) VALUES ('PC010', 'S101', 'George', 'D02', 'Testing', 16.50); INSERT INTO ProjectStaff (ProjectCode, EmployeeNumber, EmployeeName, DepartmentNumber, DepartmentName, HourlyRate) VALUES ('PC010', 'S102', 'Bob', 'D01', 'IT', 22.00); INSERT INTO ProjectStaff (ProjectCode, EmployeeNumber, EmployeeName, DepartmentNumber, DepartmentName, HourlyRate) VALUES ('PC011', 'S103', 'Jack', 'D03', 'Database', 18.50); INSERT INTO ProjectStaff (ProjectCode, EmployeeNumber, EmployeeName, DepartmentNumber, DepartmentName, HourlyRate) VALUES ('PC011', 'S104', 'Jane', 'D02', 'Testing', 17.00); INSERT INTO ProjectStaff
  • 5. (ProjectCode, EmployeeNumber, EmployeeName, DepartmentNumber, DepartmentName, HourlyRate) VALUES ('PC011', 'S315', 'Dave', 'D01', 'IT', 23.50); INSERT INTO ProjectStaff (ProjectCode, EmployeeNumber, EmployeeName, DepartmentNumber, DepartmentName, HourlyRate) VALUES ('PC012', 'S137', 'Sam', 'D03', 'Database', 21.50); INSERT INTO ProjectStaff (ProjectCode, EmployeeNumber, EmployeeName, DepartmentNumber, DepartmentName, HourlyRate) VALUES ('PC012', 'S218', 'Neil', 'D02', 'Testing', 15.50); INSERT INTO ProjectStaff (ProjectCode, EmployeeNumber, EmployeeName, DepartmentNumber, DepartmentName, HourlyRate) VALUES ('PC012', 'S109', 'Hope', 'D01', 'IT', 20.50); GO -- -- Second Normal Form -- -- 1 - First Normal Form Plus: -- -- 2 - Remove the partial dependencies(A type of functional dependency where a field -- is only functionally dependent on the part of primary key) of any non-key field. -- -- 3 - If field B depends on field A and vice versa. Also for a given value of B, we have -- only one possible value of A and vice versa, Then we put the field B in to new -- database table where B will be primary key and also marked as foreign key in -- parent table. -- CREATE DATABASE SNF; GO USE SNF; GO CREATE TABLE ProjectInfo ( ProjectCode varchar(100),
  • 6. ProjectName varchar(100), ProjectManager varchar(255), ProjectBudget Decimal(10,2) PRIMARY KEY (ProjectCode) ); CREATE TABLE EmployeeInfo ( EmployeeNumber varchar(10), EmployeeName varchar(100), DepartmentNumber varchar(10), DepartmentName varchar(100) PRIMARY KEY (EmployeeNumber) ); CREATE TABLE ProjectRates ( ProjectCode varchar(100), EmployeeNumber varchar(10), HourlyRate Decimal(10,2) PRIMARY KEY (ProjectCode, EmployeeNumber) FOREIGN KEY (ProjectCode) REFERENCES ProjectInfo, FOREIGN KEY (EmployeeNumber) REFERENCES EmployeeInfo ); GO INSERT INTO ProjectInfo (ProjectCode, ProjectName, ProjectManager, ProjectBudget) VALUES ('PC010', 'Reservation System', 'Mr. Jones', 120500.00); INSERT INTO ProjectInfo (ProjectCode, ProjectName, ProjectManager, ProjectBudget) VALUES ('PC011', 'HR System', 'Mrs. Smith', 500500.00); INSERT INTO ProjectInfo (ProjectCode, ProjectName, ProjectManager, ProjectBudget) VALUES ('PC012', 'Attendance System', 'Mr. Doe', 710700.00); INSERT INTO EmployeeInfo (EmployeeNumber, EmployeeName, DepartmentNumber, DepartmentName) VALUES ('S100', 'John', 'D03', 'Database'); INSERT INTO EmployeeInfo
  • 7. (EmployeeNumber, EmployeeName, DepartmentNumber, DepartmentName) VALUES ('S101', 'George', 'D02', 'Testing'); INSERT INTO EmployeeInfo (EmployeeNumber, EmployeeName, DepartmentNumber, DepartmentName) VALUES ('S102', 'Bob', 'D01', 'IT'); INSERT INTO EmployeeInfo (EmployeeNumber, EmployeeName, DepartmentNumber, DepartmentName) VALUES ('S103', 'Jack', 'D03', 'Database'); INSERT INTO EmployeeInfo (EmployeeNumber, EmployeeName, DepartmentNumber, DepartmentName) VALUES ('S104', 'Jane', 'D02', 'Testing'); INSERT INTO EmployeeInfo (EmployeeNumber, EmployeeName, DepartmentNumber, DepartmentName) VALUES ('S315', 'Dave', 'D01', 'IT'); INSERT INTO EmployeeInfo (EmployeeNumber, EmployeeName, DepartmentNumber, DepartmentName) VALUES ('S137', 'Sam', 'D03', 'Database'); INSERT INTO EmployeeInfo (EmployeeNumber, EmployeeName, DepartmentNumber, DepartmentName) VALUES ('S218', 'Neil', 'D02', 'Testing'); INSERT INTO EmployeeInfo (EmployeeNumber, EmployeeName, DepartmentNumber, DepartmentName) VALUES ('S109', 'Hope', 'D01', 'IT'); INSERT INTO ProjectRates (ProjectCode, EmployeeNumber, HourlyRate) VALUES ('PC010', 'S100', 21.00); INSERT INTO ProjectRates (ProjectCode, EmployeeNumber, HourlyRate) VALUES ('PC010', 'S101', 16.50); INSERT INTO ProjectRates (ProjectCode, EmployeeNumber, HourlyRate) VALUES ('PC010', 'S102', 22.00); INSERT INTO ProjectRates (ProjectCode, EmployeeNumber, HourlyRate) VALUES ('PC011', 'S103', 18.50); INSERT INTO ProjectRates
  • 8. (ProjectCode, EmployeeNumber, HourlyRate) VALUES ('PC011', 'S104', 17.00); INSERT INTO ProjectRates (ProjectCode, EmployeeNumber, HourlyRate) VALUES ('PC011', 'S315', 23.50); INSERT INTO ProjectRates (ProjectCode, EmployeeNumber, HourlyRate) VALUES ('PC012', 'S137', 21.50); INSERT INTO ProjectRates (ProjectCode, EmployeeNumber, HourlyRate) VALUES ('PC012', 'S218', 15.50); INSERT INTO ProjectRates (ProjectCode, EmployeeNumber, HourlyRate) VALUES ('PC012', 'S109', 20.50); GO -- -- Third Normal Form -- -- 1 - Second Normal Form Plus: -- -- 2 - Remove the transitive dependecies(A type of functional dependency where a field -- is functionally dependent on the Field that is not the primary key.Hence -- its value is determined, indirectly by the primary key ) -- -- 3 - Make separate table for transitive dependent Field. -- CREATE DATABASE TNF; GO USE TNF; GO CREATE TABLE ProjectInfo ( ProjectCode varchar(100), ProjectName varchar(100), ProjectManager varchar(255), ProjectBudget Decimal(10,2)
  • 9. PRIMARY KEY (ProjectCode) ); CREATE TABLE DepartmentInfo ( DepartmentNumber varchar(10), DepartmentName varchar(100), PRIMARY KEY (DepartmentNumber) ); CREATE TABLE EmployeeInfo ( EmployeeNumber varchar(10), EmployeeName varchar(100), DepartmentNumber varchar(10) PRIMARY KEY (EmployeeNumber) FOREIGN KEY REFERENCES DepartmentInfo(DepartmentNumber) ); CREATE TABLE ProjectRates ( ProjectCode varchar(100), EmployeeNumber varchar(10), HourlyRate Decimal(10,2) PRIMARY KEY (ProjectCode, EmployeeNumber) FOREIGN KEY (ProjectCode) REFERENCES ProjectInfo, FOREIGN KEY (EmployeeNumber) REFERENCES EmployeeInfo ); GO INSERT INTO ProjectInfo (ProjectCode, ProjectName, ProjectManager, ProjectBudget) VALUES ('PC010', 'Reservation System', 'Mr. Jones', 120500.00); INSERT INTO ProjectInfo (ProjectCode, ProjectName, ProjectManager, ProjectBudget) VALUES ('PC011', 'HR System', 'Mrs. Smith', 500500.00); INSERT INTO ProjectInfo (ProjectCode, ProjectName, ProjectManager, ProjectBudget) VALUES ('PC012', 'Attendance System', 'Mr. Doe', 710700.00); INSERT INTO DepartmentInfo
  • 10. (DepartmentNumber, DepartmentName) VALUES ('D03', 'Database'); INSERT INTO DepartmentInfo (DepartmentNumber, DepartmentName) VALUES ('D02', 'Testing'); INSERT INTO DepartmentInfo (DepartmentNumber, DepartmentName) VALUES ('D01', 'IT'); INSERT INTO EmployeeInfo (EmployeeNumber, EmployeeName, DepartmentNumber) VALUES ('S100', 'John', 'D03'); INSERT INTO EmployeeInfo (EmployeeNumber, EmployeeName, DepartmentNumber) VALUES ('S101', 'George', 'D02'); INSERT INTO EmployeeInfo (EmployeeNumber, EmployeeName, DepartmentNumber) VALUES ('S102', 'Bob', 'D01'); INSERT INTO EmployeeInfo (EmployeeNumber, EmployeeName, DepartmentNumber) VALUES ('S103', 'Jack', 'D03'); INSERT INTO EmployeeInfo (EmployeeNumber, EmployeeName, DepartmentNumber) VALUES ('S104', 'Jane', 'D02'); INSERT INTO EmployeeInfo (EmployeeNumber, EmployeeName, DepartmentNumber) VALUES ('S315', 'Dave', 'D01'); INSERT INTO EmployeeInfo (EmployeeNumber, EmployeeName, DepartmentNumber) VALUES ('S137', 'Sam', 'D03'); INSERT INTO EmployeeInfo (EmployeeNumber, EmployeeName, DepartmentNumber) VALUES ('S218', 'Neil', 'D02'); INSERT INTO EmployeeInfo (EmployeeNumber, EmployeeName, DepartmentNumber) VALUES ('S109', 'Hope', 'D01'); INSERT INTO ProjectRates
  • 11. (ProjectCode, EmployeeNumber, HourlyRate) VALUES ('PC010', 'S100', 21.00); INSERT INTO ProjectRates (ProjectCode, EmployeeNumber, HourlyRate) VALUES ('PC010', 'S101', 16.50); INSERT INTO ProjectRates (ProjectCode, EmployeeNumber, HourlyRate) VALUES ('PC010', 'S102', 22.00); INSERT INTO ProjectRates (ProjectCode, EmployeeNumber, HourlyRate) VALUES ('PC011', 'S103', 18.50); INSERT INTO ProjectRates (ProjectCode, EmployeeNumber, HourlyRate) VALUES ('PC011', 'S104', 17.00); INSERT INTO ProjectRates (ProjectCode, EmployeeNumber, HourlyRate) VALUES ('PC011', 'S315', 23.50); INSERT INTO ProjectRates (ProjectCode, EmployeeNumber, HourlyRate) VALUES ('PC012', 'S137', 21.50); INSERT INTO ProjectRates (ProjectCode, EmployeeNumber, HourlyRate) VALUES ('PC012', 'S218', 15.50); INSERT INTO ProjectRates (ProjectCode, EmployeeNumber, HourlyRate) VALUES ('PC012', 'S109', 20.50); Solution here are 12 queries for the database. whenever you find all columns in a single table, you just fetch it. Otherwise you have to join the 2 tables based on the matching common key... like in our example ProjectCode or EmployeeNumber. Also using table aliases its convinient to write queries in more readable and short form. ========================= for unnormalized form select ProjectCode,ProjectName,ProjectManager from Unnormalized;
  • 12. select Employeename,DepartmentNumber,DepartmentName from Unnormalized; select ProjectCode ,Employeename from Unnormalized order by ProjectCode; select ProjectName ,EmployeeName,HourlyRate, DepartmentName from Unnormalized; =========================================== for 1st normal form select ProjectCode,ProjectName,ProjectManager from ProjectInfo; select Employeename,DepartmentNumber,DepartmentName from ProjectStaff; select ProjectCode ,Employeename from ProjectStaff; select p.ProjectName ,s.EmployeeName,s.HourlyRate, s.DepartmentName from ProjectStaff s JOIN ProjectInfo p using (ProjectCode); ======================================== for 2nd normal form select ProjectCode,ProjectName,ProjectManager from ProjectInfo; select Employeename,DepartmentNumber,DepartmentName from EmployeeInfo; select r.ProjectCode ,e.EmployeeName from ProjectRates r JOIN EmployeeInfo e using (EmployeeNumber); SELECT p.ProjectName,e.EmployeeName,e.DepartmentName,r.HourlyRate FROM ProjectRates r INNER JOIN EmployeeInfo e on r.EmployeeNumber = e.EmployeeNumber LEFT JOIN ProjectInfo p on r.ProjectCode = p.ProjectCode