SlideShare a Scribd company logo
Sample 
DB Normalization and SQL query 
Normalization- 
1. Normalize the given table to its first normal form- 
Order_id Order_Item Total Cus_id 
1 Pizza, Clemon 1 1 
2 Fried chicken, Burger 3 2 
3 Burger 2 1 
Solution: 
In First Normal Form, any row must not have a column in which more than one value is saved, 
like separated with commas. Rather than that, we must separate such data into multiple rows. 
So, the given table would be changed into its first normal form as below: 
Order_id Order_Item Total Cus_id 
1 Pizza 1 1 
1 Clemon 1 1 
2 Fried chicken, Burger 3 2 
3 Burger 2 1 
2. Normalize the given table to its first and second normal form- 
Id TransactionNo FirstCompany SecondCompany TransAmount TransDate 
1 AB01109876 ABC Corp. Iqra 
Multipurpose 
Society 
CSC 433 – Shakila Mahjabin Tonni, Faculty, Dept of CSE 
1,00,000 01/10/2012 
2 JQ11118044 Sagupta 
Fashion 
ABC Corp. 15,00,000 11/11/2013 
3 AC10122043 Sagupta 
Fashoin 
Iqra 
Multipurpose 
Society 
15,00,000 10/12/2012 
4 DA02033021 ABC Corp. Sagupta Fashion 2,00,000 02/03/2013 
Solution: 
As per the first normal form’s definition, in a single row, no two column values should be 
repeated/duplicate. It is true for each row of the given table, so it is in its First normal Form.
By definition, to transform a table into its second normal form, we have to remove subsets of 
data that apply to multiple rows (multiple rows have same data for a column) of a table and 
place them in separate tables. 
Here, the company names are repeating in both FirstCompany (example, ABC Corp. came twice) 
and SecondCompany (Iqra Multipurpose Society came twice) columns. 
We can create a totally new table named Company for these names. So, after transforming the 
table in its 2NF form, we get: 
Table:Company 
Id CompanyName 
1 ABC Corp. 
2 Sagupta Fashion 
3 Iqra Multipurpose Society 
Id TransactionNo FirstCompanyID SecondCompanyID TransAmount TransDate 
1 AB01109876 1 3 1,00,000 01/10/2012 
2 JQ11118044 2 1 15,00,000 11/11/2013 
3 AC10122043 2 3 15,00,000 10/12/2012 
4 DA02033021 1 2 2,00,000 02/03/2013 
3. Normalize the given data into 1NF, 2NF and 3NF-Memb 
er_Id 
Member_ 
name 
Member_p 
osition 
Member_ 
access 
CSC 433 – Shakila Mahjabin Tonni, Faculty, Dept of CSE 
Member_a 
ddress 
Member_cont 
act 
Member_expi 
re_date 
14012 Sadiqul 
Islam 
General Loan House 56, 
Gulshan 2, 
Dhaka 
01912098234, 
8743930 
Feb, 2017 
14009 Naurin 
Alam 
Board of 
Trustee 
Company 
Share 
House 42, 
Niketon, 
Dhaka 
01729978783, 
8797268 
June, 2020 
12134 Atiquzza 
man 
Governing 
Body 
Company 
Share, 
Managem 
ent 
House 214, 
Niketon, 
Dhaka 
01819878375, 
8524632 
Jan, 2015 
11067 Kamrunn 
ahar 
General Loan House 
04,DOHS, 
Dhaka 
01718093014, 
7210784 
Dec, 2014 
Solution: 
In first normal form, no column values should contain two values (as in Member_contact 
column) separated by comma. So, in 1NF:
Membe 
r_Id 
Member_ 
name 
Member_p 
osition 
Member_a 
ccess 
CSC 433 – Shakila Mahjabin Tonni, Faculty, Dept of CSE 
Member_a 
ddress 
Member_c 
ontact 
Member_expir 
e_date 
14012 Sadiqul 
Islam 
General Loan House 56, 
Gulshan 2, 
Dhaka 
019120982 
34 
Feb, 2017 
14012 Sadiqul 
Islam 
General Loan House 56, 
Gulshan 2, 
Dhaka 
8743930 Feb, 2017 
14009 Naurin 
Alam 
Board of 
Trustee 
Company 
Share 
House 42, 
Niketon, 
Dhaka 
017299787 
83 
June, 2020 
14009 Naurin 
Alam 
Board of 
Trustee 
Company 
Share 
House 42, 
Niketon, 
Dhaka 
8797268 June, 2020 
12134 Atiquzzam 
an 
Governing 
Body 
Company 
Share, 
Managem 
ent 
House 214, 
Niketon, 
Dhaka 
018198783 
75 
Jan, 2015 
12134 Atiquzzam 
an 
Governing 
Body 
Company 
Share, 
Managem 
ent 
House 214, 
Niketon, 
Dhaka 
8524632 Jan, 2015 
11067 Kamrunna 
har 
General Loan House 
04,DOHS, 
Dhaka 
017180930 
14 
Dec, 2014 
11067 Kamrunna 
har 
General Loan House 
04,DOHS, 
Dhaka 
7210784 Dec, 2014 
But in this format, in Member_Id column, column values are repeating. We can’t take this 
column as a primary key anymore. Also, in Member_Address has repeating part. So, to convert 
into its second normal form we will create a new table from the above table named 
MemberContactDetails: 
Table: MemberContactDetails 
Id Member_contact_1 Member_contact_2 House_No AreaID 
1 01912098234 8743930 56 
2 01729978783 8797268 42 
3 01819878375 8524632 214 
4 01718093014 7210784 04 
Table: Area 
Id Area 
1 Gulshan 2, Dhaka 
2 DOHS, Dhaka
3 Niketon, Dhaka 
Write necessary SQL queries to- 
1. Create a table Customers with the following data- (Set Id as the primary key) 
Id Cus_Name Age Cus_Address Cus_Mobile Cus_Email 
1 Afroza 18 Uttara, Dhaka 01719991112 afroza@hotmail.com 
2 Redwan 20 Narsingdi, 
Dhaka 
CSC 433 – Shakila Mahjabin Tonni, Faculty, Dept of CSE 
01616889223 ripon@gmail.com 
3 Samsuzzaman 25 Kakrail, Dhaka 01718071083 sahmed@yahoo.com 
2. Show customers name and address from the above table. 
3. Show customer name from above table where name starts with ‘A’. 
4. Show customer name and age for the customers who are more than 18 years old. 
5. Create a table order and insert the following data- (Ser Order_id as the primary key) 
Order_id Order_Item Total Cus_id 
1 Pizza 1 1 
2 Clemon 5 1 
3 Fried chicken 3 2 
4 Burger 2 1 
6. Delete rows from the above table where Cus_id is 1. 
7. Add a new column named Price in the above table. 
8. Show the order_items and total from the above table and change the column names as Items 
and Total No. 
9. Show the order_item and total where total is between 1 and 4. 
10. Show the order_items and total for customer whose cus_id is 2. 
>> Complete the above tasks and submit as assignment in group via 
email within 07.11.14 
>> After 07.11.14, I’ll provide its solution to you.
Good Luck 
CSC 433 – Shakila Mahjabin Tonni, Faculty, Dept of CSE

More Related Content

What's hot

Ppt bubble sort
Ppt bubble sortPpt bubble sort
Ppt bubble sort
prabhakar jalasutram
 
Database Management Systems 4 - Normalization
Database Management Systems 4 - NormalizationDatabase Management Systems 4 - Normalization
Database Management Systems 4 - NormalizationNickkisha Farrell
 
BCA DATA STRUCTURES SEARCHING AND SORTING MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES SEARCHING AND SORTING MRS.SOWMYA JYOTHIBCA DATA STRUCTURES SEARCHING AND SORTING MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES SEARCHING AND SORTING MRS.SOWMYA JYOTHI
Sowmya Jyothi
 
Database management system Lecture 7 : Strong and weak entity sets
Database management system Lecture 7 : Strong and weak entity setsDatabase management system Lecture 7 : Strong and weak entity sets
Database management system Lecture 7 : Strong and weak entity sets
BIT Durg
 
database Normalization
database Normalizationdatabase Normalization
database Normalization
Harsiddhi Thakkar
 
Eclat algorithm in association rule mining
Eclat algorithm in association rule miningEclat algorithm in association rule mining
Eclat algorithm in association rule mining
Deepa Jeya
 
Unit1 DBMS Introduction
Unit1 DBMS IntroductionUnit1 DBMS Introduction
Unit1 DBMS Introduction
MUHAMMED MASHAHIL PUKKUNNUMMAL
 
CS 402 DATAMINING AND WAREHOUSING -PROBLEMS
CS 402 DATAMINING AND WAREHOUSING -PROBLEMSCS 402 DATAMINING AND WAREHOUSING -PROBLEMS
CS 402 DATAMINING AND WAREHOUSING -PROBLEMS
NIMMYRAJU
 
Normalization in DBMS
Normalization in DBMSNormalization in DBMS
Normalization in DBMS
Hitesh Mohapatra
 
Insertion sort bubble sort selection sort
Insertion sort bubble sort  selection sortInsertion sort bubble sort  selection sort
Insertion sort bubble sort selection sort
Ummar Hayat
 
Joins in SQL
Joins in SQLJoins in SQL
Joins in SQL
Pooja Dixit
 
Date and time functions in mysql
Date and time functions in mysqlDate and time functions in mysql
Date and time functions in mysql
V.V.Vanniaperumal College for Women
 
Rdbms terminology
Rdbms terminologyRdbms terminology
Rdbms terminology
Harish Gyanani
 
Dbms4
Dbms4Dbms4
Presentation on tablespaceses segments extends and blocks
Presentation on tablespaceses segments extends and blocksPresentation on tablespaceses segments extends and blocks
Presentation on tablespaceses segments extends and blocks
Vinay Ugave
 
Binary Search Tree and AVL
Binary Search Tree and AVLBinary Search Tree and AVL
Binary Search Tree and AVL
Katang Isip
 
Dbms Notes Lecture 9 : Specialization, Generalization and Aggregation
Dbms Notes Lecture 9 : Specialization, Generalization and AggregationDbms Notes Lecture 9 : Specialization, Generalization and Aggregation
Dbms Notes Lecture 9 : Specialization, Generalization and Aggregation
BIT Durg
 

What's hot (17)

Ppt bubble sort
Ppt bubble sortPpt bubble sort
Ppt bubble sort
 
Database Management Systems 4 - Normalization
Database Management Systems 4 - NormalizationDatabase Management Systems 4 - Normalization
Database Management Systems 4 - Normalization
 
BCA DATA STRUCTURES SEARCHING AND SORTING MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES SEARCHING AND SORTING MRS.SOWMYA JYOTHIBCA DATA STRUCTURES SEARCHING AND SORTING MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES SEARCHING AND SORTING MRS.SOWMYA JYOTHI
 
Database management system Lecture 7 : Strong and weak entity sets
Database management system Lecture 7 : Strong and weak entity setsDatabase management system Lecture 7 : Strong and weak entity sets
Database management system Lecture 7 : Strong and weak entity sets
 
database Normalization
database Normalizationdatabase Normalization
database Normalization
 
Eclat algorithm in association rule mining
Eclat algorithm in association rule miningEclat algorithm in association rule mining
Eclat algorithm in association rule mining
 
Unit1 DBMS Introduction
Unit1 DBMS IntroductionUnit1 DBMS Introduction
Unit1 DBMS Introduction
 
CS 402 DATAMINING AND WAREHOUSING -PROBLEMS
CS 402 DATAMINING AND WAREHOUSING -PROBLEMSCS 402 DATAMINING AND WAREHOUSING -PROBLEMS
CS 402 DATAMINING AND WAREHOUSING -PROBLEMS
 
Normalization in DBMS
Normalization in DBMSNormalization in DBMS
Normalization in DBMS
 
Insertion sort bubble sort selection sort
Insertion sort bubble sort  selection sortInsertion sort bubble sort  selection sort
Insertion sort bubble sort selection sort
 
Joins in SQL
Joins in SQLJoins in SQL
Joins in SQL
 
Date and time functions in mysql
Date and time functions in mysqlDate and time functions in mysql
Date and time functions in mysql
 
Rdbms terminology
Rdbms terminologyRdbms terminology
Rdbms terminology
 
Dbms4
Dbms4Dbms4
Dbms4
 
Presentation on tablespaceses segments extends and blocks
Presentation on tablespaceses segments extends and blocksPresentation on tablespaceses segments extends and blocks
Presentation on tablespaceses segments extends and blocks
 
Binary Search Tree and AVL
Binary Search Tree and AVLBinary Search Tree and AVL
Binary Search Tree and AVL
 
Dbms Notes Lecture 9 : Specialization, Generalization and Aggregation
Dbms Notes Lecture 9 : Specialization, Generalization and AggregationDbms Notes Lecture 9 : Specialization, Generalization and Aggregation
Dbms Notes Lecture 9 : Specialization, Generalization and Aggregation
 

Similar to CSC 433 Sample normalization SQL Question

Inventory management system
Inventory management systemInventory management system
Inventory management system
Md. Syful Azam
 
Impact of Normalization in Future
Impact of Normalization in FutureImpact of Normalization in Future
Impact of Normalization in Future
ijtsrd
 
Exercise 1.docx
Exercise 1.docxExercise 1.docx
Exercise 1.docx
TitaTressid
 
BBA 2 Semester DBMS All assignment
BBA 2 Semester DBMS All assignmentBBA 2 Semester DBMS All assignment
BBA 2 Semester DBMS All assignment
Roshan Kumar
 
Scd type2 through informatica
Scd type2 through informatica Scd type2 through informatica
Scd type2 through informatica Varun Hr
 
SQL practice questions set
SQL practice questions setSQL practice questions set
SQL practice questions set
Mohd Tousif
 
Correlated update vs merge
Correlated update vs mergeCorrelated update vs merge
Correlated update vs merge
Heribertus Bramundito
 
ACL London User Group - Question Box Session
ACL London User Group - Question Box SessionACL London User Group - Question Box Session
ACL London User Group - Question Box Session
Alex Psarras
 
PHP mysql Database normalizatin
PHP mysql  Database normalizatinPHP mysql  Database normalizatin
PHP mysql Database normalizatin
Mudasir Syed
 
Introduction to Databases - Assignment_1
Introduction to Databases - Assignment_1Introduction to Databases - Assignment_1
Introduction to Databases - Assignment_1
Mohd Tousif
 
Database Management System Review
Database Management System ReviewDatabase Management System Review
Database Management System Review
Kaya Ota
 
The Cube - Class XII Project
The Cube - Class XII ProjectThe Cube - Class XII Project
The Cube - Class XII Project
Neil Mathew
 
SQL practice questions - set 3
SQL practice questions - set 3SQL practice questions - set 3
SQL practice questions - set 3
Mohd Tousif
 
Inner join and outer join
Inner join and outer joinInner join and outer join
Inner join and outer joinNargis Ehsan
 
EDA of San Francisco Employee Compensation for Fiscal Year 2014-15
EDA of San Francisco Employee Compensation for Fiscal Year 2014-15EDA of San Francisco Employee Compensation for Fiscal Year 2014-15
EDA of San Francisco Employee Compensation for Fiscal Year 2014-15
Sagar Tupkar
 
6. Aggregate Functions.pdf
6. Aggregate Functions.pdf6. Aggregate Functions.pdf
6. Aggregate Functions.pdf
Sunita Milind Dol
 
SQL Server Learning Drive
SQL Server Learning Drive SQL Server Learning Drive
SQL Server Learning Drive
TechandMate
 
Final ProjectBe sure to follow the instructions for each step as.docx
Final ProjectBe sure to follow the instructions for each step as.docxFinal ProjectBe sure to follow the instructions for each step as.docx
Final ProjectBe sure to follow the instructions for each step as.docx
voversbyobersby
 

Similar to CSC 433 Sample normalization SQL Question (20)

Inventory management system
Inventory management systemInventory management system
Inventory management system
 
Impact of Normalization in Future
Impact of Normalization in FutureImpact of Normalization in Future
Impact of Normalization in Future
 
Sql wksht-6
Sql wksht-6Sql wksht-6
Sql wksht-6
 
Exercise 1.docx
Exercise 1.docxExercise 1.docx
Exercise 1.docx
 
BBA 2 Semester DBMS All assignment
BBA 2 Semester DBMS All assignmentBBA 2 Semester DBMS All assignment
BBA 2 Semester DBMS All assignment
 
Scd type2 through informatica
Scd type2 through informatica Scd type2 through informatica
Scd type2 through informatica
 
SQL practice questions set
SQL practice questions setSQL practice questions set
SQL practice questions set
 
Correlated update vs merge
Correlated update vs mergeCorrelated update vs merge
Correlated update vs merge
 
ACL London User Group - Question Box Session
ACL London User Group - Question Box SessionACL London User Group - Question Box Session
ACL London User Group - Question Box Session
 
PHP mysql Database normalizatin
PHP mysql  Database normalizatinPHP mysql  Database normalizatin
PHP mysql Database normalizatin
 
Introduction to Databases - Assignment_1
Introduction to Databases - Assignment_1Introduction to Databases - Assignment_1
Introduction to Databases - Assignment_1
 
Database Management System Review
Database Management System ReviewDatabase Management System Review
Database Management System Review
 
The Cube - Class XII Project
The Cube - Class XII ProjectThe Cube - Class XII Project
The Cube - Class XII Project
 
SQL practice questions - set 3
SQL practice questions - set 3SQL practice questions - set 3
SQL practice questions - set 3
 
Inner join and outer join
Inner join and outer joinInner join and outer join
Inner join and outer join
 
EDA of San Francisco Employee Compensation for Fiscal Year 2014-15
EDA of San Francisco Employee Compensation for Fiscal Year 2014-15EDA of San Francisco Employee Compensation for Fiscal Year 2014-15
EDA of San Francisco Employee Compensation for Fiscal Year 2014-15
 
Dbms record
Dbms recordDbms record
Dbms record
 
6. Aggregate Functions.pdf
6. Aggregate Functions.pdf6. Aggregate Functions.pdf
6. Aggregate Functions.pdf
 
SQL Server Learning Drive
SQL Server Learning Drive SQL Server Learning Drive
SQL Server Learning Drive
 
Final ProjectBe sure to follow the instructions for each step as.docx
Final ProjectBe sure to follow the instructions for each step as.docxFinal ProjectBe sure to follow the instructions for each step as.docx
Final ProjectBe sure to follow the instructions for each step as.docx
 

More from Shakila Mahjabin

Computer processing
Computer processingComputer processing
Computer processing
Shakila Mahjabin
 
Arrays in CPP
Arrays in CPPArrays in CPP
Arrays in CPP
Shakila Mahjabin
 
SQL : introduction
SQL : introductionSQL : introduction
SQL : introduction
Shakila Mahjabin
 
Normalization
NormalizationNormalization
Normalization
Shakila Mahjabin
 
Solution of Erds
Solution of ErdsSolution of Erds
Solution of Erds
Shakila Mahjabin
 
Entity Relationship Diagram
Entity Relationship DiagramEntity Relationship Diagram
Entity Relationship Diagram
Shakila Mahjabin
 
Ch1- Introduction to dbms
Ch1- Introduction to dbmsCh1- Introduction to dbms
Ch1- Introduction to dbms
Shakila Mahjabin
 
Stack and queue
Stack and queueStack and queue
Stack and queue
Shakila Mahjabin
 
Algo analysis
Algo analysisAlgo analysis
Algo analysis
Shakila Mahjabin
 
Merge sort and quick sort
Merge sort and quick sortMerge sort and quick sort
Merge sort and quick sort
Shakila Mahjabin
 
Codes on structures
Codes on structuresCodes on structures
Codes on structures
Shakila Mahjabin
 
Arrays
ArraysArrays
array, function, pointer, pattern matching
array, function, pointer, pattern matchingarray, function, pointer, pattern matching
array, function, pointer, pattern matching
Shakila Mahjabin
 
String operation
String operationString operation
String operation
Shakila Mahjabin
 
Data Structure Basics
Data Structure BasicsData Structure Basics
Data Structure Basics
Shakila Mahjabin
 

More from Shakila Mahjabin (15)

Computer processing
Computer processingComputer processing
Computer processing
 
Arrays in CPP
Arrays in CPPArrays in CPP
Arrays in CPP
 
SQL : introduction
SQL : introductionSQL : introduction
SQL : introduction
 
Normalization
NormalizationNormalization
Normalization
 
Solution of Erds
Solution of ErdsSolution of Erds
Solution of Erds
 
Entity Relationship Diagram
Entity Relationship DiagramEntity Relationship Diagram
Entity Relationship Diagram
 
Ch1- Introduction to dbms
Ch1- Introduction to dbmsCh1- Introduction to dbms
Ch1- Introduction to dbms
 
Stack and queue
Stack and queueStack and queue
Stack and queue
 
Algo analysis
Algo analysisAlgo analysis
Algo analysis
 
Merge sort and quick sort
Merge sort and quick sortMerge sort and quick sort
Merge sort and quick sort
 
Codes on structures
Codes on structuresCodes on structures
Codes on structures
 
Arrays
ArraysArrays
Arrays
 
array, function, pointer, pattern matching
array, function, pointer, pattern matchingarray, function, pointer, pattern matching
array, function, pointer, pattern matching
 
String operation
String operationString operation
String operation
 
Data Structure Basics
Data Structure BasicsData Structure Basics
Data Structure Basics
 

Recently uploaded

Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
Col Mukteshwar Prasad
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
Vivekanand Anglo Vedic Academy
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
Celine George
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
PedroFerreira53928
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
AzmatAli747758
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
Excellence Foundation for South Sudan
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
rosedainty
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
Steve Thomason
 

Recently uploaded (20)

Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 

CSC 433 Sample normalization SQL Question

  • 1. Sample DB Normalization and SQL query Normalization- 1. Normalize the given table to its first normal form- Order_id Order_Item Total Cus_id 1 Pizza, Clemon 1 1 2 Fried chicken, Burger 3 2 3 Burger 2 1 Solution: In First Normal Form, any row must not have a column in which more than one value is saved, like separated with commas. Rather than that, we must separate such data into multiple rows. So, the given table would be changed into its first normal form as below: Order_id Order_Item Total Cus_id 1 Pizza 1 1 1 Clemon 1 1 2 Fried chicken, Burger 3 2 3 Burger 2 1 2. Normalize the given table to its first and second normal form- Id TransactionNo FirstCompany SecondCompany TransAmount TransDate 1 AB01109876 ABC Corp. Iqra Multipurpose Society CSC 433 – Shakila Mahjabin Tonni, Faculty, Dept of CSE 1,00,000 01/10/2012 2 JQ11118044 Sagupta Fashion ABC Corp. 15,00,000 11/11/2013 3 AC10122043 Sagupta Fashoin Iqra Multipurpose Society 15,00,000 10/12/2012 4 DA02033021 ABC Corp. Sagupta Fashion 2,00,000 02/03/2013 Solution: As per the first normal form’s definition, in a single row, no two column values should be repeated/duplicate. It is true for each row of the given table, so it is in its First normal Form.
  • 2. By definition, to transform a table into its second normal form, we have to remove subsets of data that apply to multiple rows (multiple rows have same data for a column) of a table and place them in separate tables. Here, the company names are repeating in both FirstCompany (example, ABC Corp. came twice) and SecondCompany (Iqra Multipurpose Society came twice) columns. We can create a totally new table named Company for these names. So, after transforming the table in its 2NF form, we get: Table:Company Id CompanyName 1 ABC Corp. 2 Sagupta Fashion 3 Iqra Multipurpose Society Id TransactionNo FirstCompanyID SecondCompanyID TransAmount TransDate 1 AB01109876 1 3 1,00,000 01/10/2012 2 JQ11118044 2 1 15,00,000 11/11/2013 3 AC10122043 2 3 15,00,000 10/12/2012 4 DA02033021 1 2 2,00,000 02/03/2013 3. Normalize the given data into 1NF, 2NF and 3NF-Memb er_Id Member_ name Member_p osition Member_ access CSC 433 – Shakila Mahjabin Tonni, Faculty, Dept of CSE Member_a ddress Member_cont act Member_expi re_date 14012 Sadiqul Islam General Loan House 56, Gulshan 2, Dhaka 01912098234, 8743930 Feb, 2017 14009 Naurin Alam Board of Trustee Company Share House 42, Niketon, Dhaka 01729978783, 8797268 June, 2020 12134 Atiquzza man Governing Body Company Share, Managem ent House 214, Niketon, Dhaka 01819878375, 8524632 Jan, 2015 11067 Kamrunn ahar General Loan House 04,DOHS, Dhaka 01718093014, 7210784 Dec, 2014 Solution: In first normal form, no column values should contain two values (as in Member_contact column) separated by comma. So, in 1NF:
  • 3. Membe r_Id Member_ name Member_p osition Member_a ccess CSC 433 – Shakila Mahjabin Tonni, Faculty, Dept of CSE Member_a ddress Member_c ontact Member_expir e_date 14012 Sadiqul Islam General Loan House 56, Gulshan 2, Dhaka 019120982 34 Feb, 2017 14012 Sadiqul Islam General Loan House 56, Gulshan 2, Dhaka 8743930 Feb, 2017 14009 Naurin Alam Board of Trustee Company Share House 42, Niketon, Dhaka 017299787 83 June, 2020 14009 Naurin Alam Board of Trustee Company Share House 42, Niketon, Dhaka 8797268 June, 2020 12134 Atiquzzam an Governing Body Company Share, Managem ent House 214, Niketon, Dhaka 018198783 75 Jan, 2015 12134 Atiquzzam an Governing Body Company Share, Managem ent House 214, Niketon, Dhaka 8524632 Jan, 2015 11067 Kamrunna har General Loan House 04,DOHS, Dhaka 017180930 14 Dec, 2014 11067 Kamrunna har General Loan House 04,DOHS, Dhaka 7210784 Dec, 2014 But in this format, in Member_Id column, column values are repeating. We can’t take this column as a primary key anymore. Also, in Member_Address has repeating part. So, to convert into its second normal form we will create a new table from the above table named MemberContactDetails: Table: MemberContactDetails Id Member_contact_1 Member_contact_2 House_No AreaID 1 01912098234 8743930 56 2 01729978783 8797268 42 3 01819878375 8524632 214 4 01718093014 7210784 04 Table: Area Id Area 1 Gulshan 2, Dhaka 2 DOHS, Dhaka
  • 4. 3 Niketon, Dhaka Write necessary SQL queries to- 1. Create a table Customers with the following data- (Set Id as the primary key) Id Cus_Name Age Cus_Address Cus_Mobile Cus_Email 1 Afroza 18 Uttara, Dhaka 01719991112 afroza@hotmail.com 2 Redwan 20 Narsingdi, Dhaka CSC 433 – Shakila Mahjabin Tonni, Faculty, Dept of CSE 01616889223 ripon@gmail.com 3 Samsuzzaman 25 Kakrail, Dhaka 01718071083 sahmed@yahoo.com 2. Show customers name and address from the above table. 3. Show customer name from above table where name starts with ‘A’. 4. Show customer name and age for the customers who are more than 18 years old. 5. Create a table order and insert the following data- (Ser Order_id as the primary key) Order_id Order_Item Total Cus_id 1 Pizza 1 1 2 Clemon 5 1 3 Fried chicken 3 2 4 Burger 2 1 6. Delete rows from the above table where Cus_id is 1. 7. Add a new column named Price in the above table. 8. Show the order_items and total from the above table and change the column names as Items and Total No. 9. Show the order_item and total where total is between 1 and 4. 10. Show the order_items and total for customer whose cus_id is 2. >> Complete the above tasks and submit as assignment in group via email within 07.11.14 >> After 07.11.14, I’ll provide its solution to you.
  • 5. Good Luck CSC 433 – Shakila Mahjabin Tonni, Faculty, Dept of CSE