You are on page 1of 8

Class-1: Theory

---------------
what? Microsoft SQL Server(Database management software) - SQL (Structured query
language)

why? SQL - It is the very core/ fundamental language in software industery

how? weekend batch - 3hr - 24hr live class (1st half - 15min break - 2nd half)

RDBMS(Structured) - MS-SQL Server, Oracle, DB2, mysql, Postgres

SQL

NoSQL(Bigdata/Unstructured) - MongoDB, Redis, Cassandra, CouchDB, DocumentDB,


AuroraDB

HA , HA-DR

DBMS - MS-SQL Server, Oracle, DB2, MySQL, Postgres etc.

Application Layer:
User Interface - HTML, CSS
Applicatation layer - c#, java
Database layer - SQL

Client Server Architecture - Google, Facebook, insta, Amazon, YouTube


OLTP - Online Transaction Protocol

-- What is client server architecture?


-- What is data consistency?

-- Command types:
DQL, DDL, DML, DCL

file-1: 'My name is Rahul, my age is 20'


file-1-Copy: 'My name is Rahul, my age is 20'

person(ID, Name, Age)


1, Priya, 25
2, Trimala, 26
3, Mahesh, 26

1 --> 25
2 --> 26
3 --> 26

2 --> 26/27

DBMS -- server name


Databases
Tables
Data

Name: Trupti

User1- What is the name of studentid - 10? Trupti


User2- What is the name of studentid - 10? Sarada

-- What is normalization?
Technique to minimize data duplication and increase logical consistency.

-- Why to perform normalization?


Remove redundancy from database tables
Maintain consistency and integrity

-- What is consistency?
there should not be any data mismatch between different acess.

-- what is integrity?
If the data is consistent that means the table maintainded its integrity.

anomalies without nornalization?


Redundency, Insert,update,delete anomalies

Person(SSN, Name, Age, Address)


SSN --> Name

-- what is dependency?
It is the logical relation between two columns in a table.

-- Funtional dependency:
A cell value in a row can uniquely determine the other cell values of the same row

-- Functional dependency
A --> B If for the value of A there is a unique value of B
a1 --> b1
a1 --> b2
Here for the value of A as a1 we are not getting unique value of B
as there two values of B as b1 and b2

Person(PID, PName, PAge)


1, Raj, 10
2, Riya, 20
3, Nita, 10
4, Rohit, 15
PID --> Age
1 --> 10
3 --> 10

1 --> 10
3 --> 10

4 --> 15
4 --> 20

-- Full Functional dependency


Student(roll_num, Name, course_id, Subject, Grade)
xyz --> W

roll_num, course_id --> grade


(1, CSE301) --> A
(1, CSE306) --> C
(2, CSE301) --> B
(2, CSE306) --> A
(3, CSE316) --> C

Roll_num, Subject --> Grade


(1, DBMS) --> A
(1, DS) --> C
(2, DBMS) --> B
(2, DS) --> A
(3, AI) --> C

-- Partial Functional dependency


Employee(emp_id, emp_name, emp_Age, emp_contact, Manager)
100, Abhi, 25 -->

emp_id --> emp_name, emp_Age, emp_contact, Manager


emp_id,emp_name --> emp_Age, emp_contact, Manager
emp_id, emp_name, emp_Age --> emp_contact, Manager

emp_id, emp_name --> Manager


emp_id --> emp_name, Manager

Table(A,B,C,D,E)
A --> B,C,D,E
A,B --> C,D,E
A,B,C --> D,E

-- A candidate key is a super key but the opposit is not true.

-- Super Key: A superkey is a combination of columns that uniquely identifies any


row within a table.
-- Candidate Key: A Candidate key is a subset of Super key without any unnecessary
attributes for uniquely identifying rows.
-- Prime attribute: An attribute that is a part of one of the candidate keys is
known as prime attribute.
-- Non Prime attribute: An attribute that is not part of the candidate keys is
known as non prime attribute.

Note: All the candidate keys are super key but all the super keys are not candidate
keys.

Class-2: Theory M1.2 P67


---------------------------------
LMS walk through Session 15-20min

-- Transative Functional Dependency


PersonDetails(ID, Name, Age, AreaCode, Street, City)

ID --> Name, Age, AreaCode, Street, City

ID --> Name
ID --> City

ID --> AreaCode
AreaCode --> City

ID --> City --> transative in nature

ID --> AreaCode
AreaCode --> City
ID --> City

EmployeeDetails(EID, E_Name, Department, Base_Location)

EID --> Department


Department --> Base_Location
EID --> Base_Location

a --> b
a --> b
a --> b

-- Multivalued Functional Depedency: (Special case)


When there are more than one independent multivalued attribute in a table.

Example:
PersonDetails(ID, Name, Age, country, nationality)
1, raj, India, Indian
2, Bob, US, American
3, Puja, India, Indian
4, Liza, US, American
country --> nationality
India --> Indian
US --> American

Model --> --> Year

col1, col2, col3, col4, ....

Student(S_ID, S_Name, S_Age, S_Contact)


CarDetails(Car_Name, Car_Model, Brand_Name)

-- Decomposition

-- Loss less join decomposition


Table(a,b,c,d,e,f,g,h)
Table1(a,b,c,d)
Table2(e,f,g,h)
Table = Table1 U Table2

Student(SID, SName, SAge, SAddress, SContact)


Student1(SID, SName, SAge)
Student2(SID, SAddress, SContact)

Student = Student1 U Student2

-- Dependency preserving decomposition

Table(a,b,c,d,e,f)
a --> bc -- a,b,c
d --> ef -- d,e,f

Table1(a,b,c)
Table2(d,e,f)

Table1 U Table2
a --> bc
d --> ef

-- If the related columns of any functional dependency present is a table then only
we can retain the dependency

PersonDetails(ID, Name, Age, AreaCode, Street, City)


ID --> Name, Age
AreaCode --> Street, City

PersonDetails1 (ID, Name, Age)


PersonDetails2 (AreaCode, Street, City)

PersonDetails = PersonDetails1 U PersonDetails2


PersonDetails(ID, Name, Age, AreaCode, Street, City)
ID, Name, Age, AreaCode, Street, City
ID --> Name, Age

PersonDetails1 (ID, Name, Age)


PersonDetails2 (AreaCode, Street, Age)
PersonDetails3 (ID, City)

Dependency Preserving Decomposition --> PersonDetails1


Loss less join decomposition --> met

lossless join decomposition --> All the columns should be preserved in the sub
tables
Dependency preserving decomposition --> All the funtional dependencies should be
preserved

-- decompose student table into two sub tables using lossless join decomposition
technique
Student(SID, S_Name, S_Age, S_Address, S_Contact, S_Gender)

Student1(SID, S_Name, S_Age)


Student2(SID, S_Address, S_Contact, S_Gender)

-- decompose student table into two sub tables using dependency preserving
technique
Student(SID, S_Name, S_Age, S_Gender, S_AreaCode, S_Address, S_City)

SID --> S_Name, S_Age, S_Gender


S_AreaCode --> S_Address, S_City

Student1(SID, S_Name, S_Age, S_Gender, S_City)


Student2(SID, S_AreaCode, S_Address, S_City)

Student1(SID, S_Name, S_Age)


1, Anushka, 25
3, Prince, 26
2, Roland, 28

---------------------------Normalization---------------------------------
-- What is normalization?
Technique to minimize data duplication and increase logical consistency.

-- Why to perform normalization?


Remove redundancy from database
Maintain consistency and integrity
Person(ID, Name, Age)
1, Raj, 20

-- First Normal Form:


Rule-1: Single valued columns
Rule-2: same kind of data in each column
Rule-3: All column name should be unique
Rule-4: FYI - Row/ Column order does not matter

-- Second Normal Form:


Rule-1: Table should follow first normal form
Rule-2: No partial depedency in a table

-- Third Normal Form:


Rule-1: Table should follow second normal form
Rule-2: No transative dependency in the table

roll --> pin


pin --> state, city, district

roll --> state, city, district (remove)

RDBMS --> Relational Database Management System


online food delivery app:
customer(cid, cname, ccontact)
order(oid, oname, oprice,cid)

-- BCNF: Boyce - Codd Normal Form (Extension of third Normal Form)


Rule-1: Table should follow third normal form
Rule-2: For X->Y, X should be the candidate key of the table
: Key column of a table should be determining all other columns of the table

-- Forth Normal Form:


Rule-1: Table should follow BCNF
Rule-2: Table should not have multi valued depedency.

eid, cert, hobby

1, java, music
1, java, Dance
1, java, Writing,
1, java, Books

eid --> cert (multivalued dependency)

Table1(eid, cert)
1, java

Table2(eid, hobby)
1, music
1, Dance
1, Writing
1, books

-- Hotel management
-- problem statement
-- requirement gathering
-- requirement analysis
-- design / database design --> ER Diagram
-- database implementation
-- test
-- stage
-- feedback

You might also like