0% found this document useful (0 votes)
8 views

Class 12th Complete Notes

The document discusses various programming concepts related to modules, functions, file handling, and data structures in Python. It covers how to import modules, define functions with parameters, handle files in different modes (read, write, append), and introduces data structures like stacks and queues. Additionally, it provides examples and syntax for performing operations on these elements.

Uploaded by

class9.jss
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Class 12th Complete Notes

The document discusses various programming concepts related to modules, functions, file handling, and data structures in Python. It covers how to import modules, define functions with parameters, handle files in different modes (read, write, append), and introduces data structures like stacks and queues. Additionally, it provides examples and syntax for performing operations on these elements.

Uploaded by

class9.jss
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 100

ATE

Patson Modules
A module. Ruthon a fle.
Containn Pt CodeCKmch on, claseA,
that Can be euJed
otherr
qm
Modle
imoat statememt
im pont Cmodule. -name
Cmodule
<module-name,<hnction>) # yjng module
fnchon
tsnm tahememt

tom Kmodule namme) imgont tmei, fune2


Runci(
wrthout mo dle names

Also
fnc 2(
But it not eCemmended,

Jmpost a module lwith an Aliay (nichname


we
module Shos tes alias
Gaample impont math
mt(nS4d(2r)) # S.o
pnat (m-pi) #3141s.. ..
Step stop-i,
wth to
nteaegtsom
dtat dunn 0an Retu 4
shetop, (stact ome rond on (ran d a'nnt
mclosive) (hoth b and a
between intenen TAmdom
Ca, andint
CandmT Lont
fas, ange the
ambes poinAloatng-
t Retuns
a #
pontramdem
Mole Rand
om #
iOsadins) ’Tanaent
Cin tanCmathpi) math:
10gadiams) Cin Come
mathcos(mathpi

-0 raians) @n
l)’Sme math:pi (inmath
loS Valve Absslote E(o:s) mathfab
ower (2,3)’ aathpouw
oLJN Rocmd
(4:2) lo9,n math
5-0
mateh
valve Rehms mathpi
odules math emtrs pont tin nath impont
Module Matth
PAGE
DATE
emt frea Most mode
lve amicle mediam’
Cdata) Stahihca:
mode frnt
#4
=L2,3,3,411,
S,6] data
valwe
occ most Show mode cawe IBe
(data mode (Statish
ca. pnnt
Cdata) prnt(tta
median tuihica:
30 data)) fnnt(stauhhe:
mean(
30-0 #
so) 30,40, 20, Cio, data
=
stics Jtati mpant
Mode edian, Mean Module thei Sta
Woniking
APnchon re0g able block code
that pertoms
pexfaom Speife. task.

pre-dehned Vsesdened
len)
(Cai Jantak( o)
pant ('Hetto")
Name of
the Rnchon -Ayment
Rnchroni
Jet Bom as): del Som (at):
etum atb phnt (at b)

Thi
the value but This omy pnts
docont pont. Value
retum
but does n't
mum= Jum
mum= Jum (1,5)J
wil) have num will have
the etned valve 'None'
but we con do But this nctn Call
will
pint the yetu nedvale
Calling a kmchan
Jheet();
|pmat ("tello)
pnnC kaise he?)

Calaggret ()
Pamameles V/s Argmtot
def Jom (a, b):

pnnt (atb)

(a, b)’ (at the hime 'of de


’ Cam be Ca \led
Porsametes,
frmal Pamete,
fromal Aqument
Cc,t(at the. thme od
Can be called
caling ’
Angment,
kash Actual Argyme nt
Acal Parometeg.
osrhanal Default keyurd
Amyments
t+ Post ona l Arqumcath (
Reqned):
det Jum (a, b):
pnot ("procesing ")
pnat (aty )

Sum Cyd)
’The va loe ct c goes to Onders
Mattes

* Delauit igmati :
Defaslt
must be
ayguent
det Sum Co, b,e=2): Side

prnt (atbt)

OUTPUT:

I3

pmt (d, e, ?)
pmnt (3, e)
4ccessble
at ’hobal
ypes Twleopes
) leve local
l Local
at) onlg ccesible a
Out to
Beope
Sespe.
not cause ßec eor, hireo ’
(name) pnat
Hello
jneet
()
Nl') phiat(noimye telo, Hello' Soytello
Ragat'
gneet(): mame
Vamasles ot
detSape
*
ogmenb keywe
Can we
2.
eall fmchon
parmetrn tme the at
pnt(atbtc)
(ayb,c): pnat
onmygment Keyone det Sum *
(Named) onmyment
Houw
Vamable 9

L’¬’6’B Rule

How to mahe local Vaiable

’Use Glebal heywere


grect ():
jname Raynath t ll be local qnly
aleal name = Ranat?
name
Say Hello Hella'

pnt (name )

puti:
(utput Hello Ranat
Rgnatt
fle
e han a
bony to ef opeuton
lhue cocohnË, reading
delehng Re unhng, apendj
enables
P s s to nteact with kles
Stoned on the
persistent data Jtonage and setr
ieval.
Alasslote Path V Relatye Pata
Awoloe Pat : The ath gen tom Toot
E: le

Relahve path : The path frm Curemt


directrg
Data fles: Ay kle
tLat contama Jome
2Textt data.
Gea
csv Gles
Binay hiey ’ dat files
Ome shot dekh na-.
me wama
poblem
hogi ! Somajhne
Read Mole ('y)
’ Aprend Mode ('a)
Wnte Mode (prevooy data \
To open Rles, ('u') will be lost

yhle open(Rie Handing tut")


Default
ead mode
shle open ("Ale Hemdig
tt,
Ele Ohet/ wote mode
fle Han dle

eMist but
gead mode ’ Cr opened
Warte node ’ Creates CFle Not foumEor)
tat Rle
append mode ’ Creates that fle.
Ahere Some mse wmodes !
attach the table.
Text File Binary File
Mode Mode Description Notes

'r' 'rb' read only 3 Default mode ; File must exist already, otherwise Python
raises I/Oerror.
'w' 'wb' write only If the file does not exist, file is created.
* If the file exists, Python will truncate existing data and
over-write in the file. So this mode must be used with caution.
'a' 'ab' append File is in write only mode.
If the file exists, the data in the file is retained and new data
being written will be appended to the end.
$ If the file does not exist, Python will create a new file.
'r+' 'rtb' or read and write File must exist otherwise error is raised.
'rb+'
$ Both reading and writing operations can take place.
'w+' 'w+b' or write and read File is created if does not exist.
'wb+'
If file exists, file is truncated (past data is lost).
* Both reading and writing operations can take place.
'a+' 'atb' or write and read File is created if does not exist.
'ab+'
If file exists, file's existing data is retained ; new data is
appended.
Both reading and writing operations can take place.
Cloxng fles aftey opeahon
(To bcak he link bl fle handle ond Gle

Opem ("kletHandlngtt')
#perfmmopeabons
hle-close ()
# Reading from tet
ophona Ales (ta+)
(itut (n charackon)
"seadln) : Reads n'
2 emire line
"Nead line(n) : Redy n? Qses by tes fom
3) emh line not spefed
neadines: Read all lme
element
amd
of
etn

data = wghle sead (s)


data my hle.ytad C
"nead (c)
dat myhleea dlime Cs)
"neadime (Cn3)
data =

"eadlines C
ato mghle: reud lmes()
mhle-lwnte (wte tis tone 3)

myhle-wsrte(his is imei A\n Line 2")


2) hle.
myfle-canitelinesLine i\n" Line \n"',
Linesn,Line 4"J)
TA
and pefom these oppemd mode ('a)
append
the con tent ope ratoms, it will
without the pevioUJ
Content.
# Hush fonction
myhile Ausht)y
qrekiy ends
data) to to destnat bufter datan (uaihng
# Removm white Spaces Prm
open (n poe m.tu t ')
Cnample
Use
Jine
Jne me
Jine = ineStnp ('\n')
prntCLine)
1) inestrnp
(B'\n)’emores qiven characted
trom both emds
2) ne $hp(\')’ remoarts Jrven cLas
tom inut
3) Aine-
dshopC'n)Temovs qiven
from left: Gha
panteg is at
le when opemed mode
wite m ode
Got
at the a emd
end ef the ie con tent whem
opemed ppemd mode
wamaye the posrtn of ponters we have!
4he fte ponters
Rite ¿ren
pote.
posihon.
2)
myhle tell() ’’ Retrw
Retvm crent posihn
pointer.
# Binan Aleg Modyle i needed
impont prckie
Binoy

binangidat" w)
Oats Binang ftes also called pisklig
prcxle dmp(content to be wnie , <Bte Hamdle)
Cx: pckle dumyp ("Hello ", ghte ) dmp is also
4ppend
mode

Readin fle (ao called g


(obgct
<varab le (obect vnprckling)
=preute Aoad(<hle kamdle>)
data =pale lead (my hle)
#CV Bles (Comme
Jepurated Valves)
O module needed t
mamaye
impont civ
myhle = open ("sheet d t"w'e line's
myle.close (
onto CIV Kles
we nee to impont cJu modole and
CTtate ob;ect Cwnrter oyect ) to
wte.

impont Chv

CiVwwter =cjV. wntesC myfle)


Cwite O5ject
1) (wnitr ob,ect>. wnte ow()’ Wntes one gow

CsV_wnites.wniteous (C1', 'Ramat'y s])


<wite obcctWte Ouy wmteJ b mulhple

Gample:
CsV-nte wnte Tow(c'2', 'Aqosh', qo'3,
C°3', 'Aat', 803,
C'4,eel?, 3s '3,
C's', 'Jobh ny',$6'3
Rexdng m csv fley
Inprt CTcate Teades
object
-impont ciu
mhle open ('
yhieentcv',newline'l)
CsVtaden - chu.yeaden (mhle)
all he lines:

Csv_tadeg:
pont Ci)
2) Readmg all the
elememt Iines
CJv Yeader:
pnnt (i)

pontj)

Cam also open Bles Ble


tat binagy /esv) with cnothe method
we do not hawe to close le handle
(ie myle.doe ()) this method:
Caample :
|impont
with open (stwdentcsv'
newline \n) a
myfile:
# ope ration 2
tt operuton 3
# opera tem
¬acephn Handn1
avo r ond pesfoom Some othes
task
Enam ple
we Know name

b=0

|exce pt Zeno iviJronEos:


lpnnt ( Jomemething went usmg")
we
do't Wnow mame

pnnt ( a/u)
encept:
oemt wmg")
Data Stvhses (Stack)
(ts pet
l202S
Data tctne:A Jata Jhcte
of ogzi toning omd mana
eRkheremtly
efferenth to penfosm
acces, Tnsenhom, and
openateons
deletor
Data Stvcure Ctypes)
Linean Datu Shvctes 2) Non- Lin ear Data sh.

Here, data
Here, datu is
hieraschically
Sepen tray Complen tlahohyps
GL: Irees
Linked List
Stackyi
Qoeves

Tn allabus
V/s Qoeueg Tmyprntat
Bot lnear dat shucturea, but
Stack olow LIFO - Last In fiat Out phaciple
ie, element in Jented at ast Cwill be
deleted fint. ( Like Os des of Books kept
One above o thes)

Queue Pllos fIFO- fat In fat Qot prncspe.


#Stacs
’Lineans Data Sto.
’followy LIfO promuple
’Tnsen hon amd Deleho n tokes place
Cly at Stacks top.
#Ermple of tack
We have Some numbe: 6, 3, to
We have to store it Stack.

we will implememt Stack


we Can in seot elememt ne me

Stuck
Step-0) we have em
Stack
step-1) Lseot elements CNmbes) ne me

top

Step-) Test 2 step-4) usest 3: 3

Step-3) Lnsest S Step-s)est lo;


S
2

6
And Delehion caen only happem to the
top elememt
C: we hae:
top
3

’ Dele te (ue call + pop'nn tems sf stack)


3 |top
S to’Get Lot

#Teminales fon
to Stack:
elememt.
i) PusH Opeaton: Tnseathon
: De lethon n element (top)

i) Peex : Showhe element at top.


Stack
iv) Oveglow: (EoT) when. the Si2e
iS ed and Size Roll,
Can not stooe mye element(pu)
fuithes.
v) UndenHow: (Eysor) hen the Stack u
UJen tnes to Pop
pop rom
the
* Gefone mplemen Stack
keep mindi
’ Luts in reJr zable,
So we do not Case abou ovestlow conditien
here
’Wth each push operatien, top alo increases
’wth each pop operahom, to p auo cecreaen.
>Wlen we pop, make suvse, the list Cstack) iSnt cmpty
mple ment Stack w Lut in
Tmpon tant!|| Ve
acthce itit a much possible
view this prgram at
Joun beok
ou ma
beter eada bilit
def is
retm Tve
else will attach
tum false
def Push Cstk, tem)
stkappe (item) tni mehnat
top jenCtx)-) bekaa me
def Pop (st):
if isEmpty Cs)
rekm nde sPlow?
else:

if Jen(st) ==0:
top = 0
Q. WAP to implement Stack using List in Python
def isEmpty(stack):
if(len(stack)==0):
return True
else:
return False
def push(stack,e,top):
stack.append(e)
top+=1
print(e,"is pushed!")
def pop(stack,top):
if(isEmpty(stack)):
Tough lag raha ho
print("Underflow!")
else: to video dekh lo
top-=1
item = stack.pop()
print(item,"is popped!")
Click here
def peek(stack,top):
if(isEmpty(stack)):
print("Underflow!")
else:
print(stack[top],"is at top!")
def display(stack):
print("Stack :",stack)
stack = []
top = -1
while(True):
print('''1.Push
2.Pop
3.Peek
4.Display
5.Exit''')
choice = int(input("Enter choice : "))
if(choice == 1):
e = int(input("Enter element to push : "))
push(stack,e,top)
elif(choice == 2):
pop(stack,top)
elif(choice == 3):
peek(stack,top)
elif(choice == 4):
display(stack)
elif(choice == 5):
break
else:
print("Invalid Choice!")
Date

Page |

Computen Nehaonks
valhtem afmehonkimgA
*Cmpues hehnk Cemputen netOn k
S a collectm intesconnected dévices
Hhat emmmieate Qhane

Vetnks enable data shamna

CommumItatiom beee.

Fuolytrn Netosking
1: ARPANET FomdatioM Mode n

Devalaped by ARPA Advanced Reiee


o De femt

’Man punpose
decemtsalized Communtcatie
CoEate

that Could Sunuie


netonk Palsnes
he dat to be brken to
preles Sent mdependent
Payo |

2NSNET (1986 &Net9onkiaa


’Daeloped
foundaho0
’ a Cormect academc Cnd reAearsch
ARANETS capablhes
Redaced ARaPANET 4e
Hhe bachbone
nehos king
3Tae Daksuat C19î0: -Rreaea)-Tue Calolal
Netonk

’ BaseA Tcelie
olobalComvn micatcm
pnotool, allong
’1ntroductn to helem metonkS
len ophes fon
hiah peed
Coynnnicatenbunes
Vn 0ne,
educaticn, makng
ntencen nec ted. 0
the
Date

Page |

Inanafeonng dsgtal amalo data

Commmeaten
OdeviceA
medim

device mitrates
Semds the.

( Receires he deviLe. thcat the

)fMesa data bena


tsntted tenma audio,et

(J)Cummit atiom Meia

he atne lex medim hoah


which data tsawmithed

par cable,
Coanral cablea,
frbeers Ophe Cables.
()Winelesa : Radro Laues
Mcwaves
Tufeared
Jatell:te Commmicaten
Date |
Page |

e) Parotcols :Set les


datu
temden
Com mmIc atien
ud receives
beheemm

Popalan otocols
Contol Rotoa)

Used on

fsatocol: Used
tramafes fiea
alesnng
email
Prrotocol
Cummmicatom

om municabem Media
Bamddta
’lhe, maImm data tsafes ate
of medim.
’ MeadyNed pen
’Hrahesn bandLwrdth tutes data transfes.
Date

Page |

() DataTateo Rate
he achval speed at which data
tnammtted
’ ARecteb mehaon Congeshon, mlerslexence,,
nd hare Limtatens

’ A vnique nUmenical label


device metwonk
’Used deuces
Coonet deta delrey

PT CTatesmch Paotocol Vealken -


32 bit addseA

’Te(Tntemei PostocoL Vessron 6)


122-br+ addres Aos lanen adde
Jpace
Pullic PivaheTP Addseies:
Pulse Le: Used the Lnteomet

local
wrthin CA

netuonK (eq 192-162.Xx, lo- X. X-X)


Date |

Page |

are method
dat metwonks.
Asanfen
’A edicated OcommuMcatom path
establesaed befone. data tsonmillrom
thonal
Gxampe metnki
Aelegphohe.
’ Poo: Reliable minimal date

’Coms:aate banddta when


idle

’Date
Date is benmto Small pachet
each Sounce deshnion

’Crample Used tthe TatemetVoIP,


Cnline

meed on C dedcated
path.
Com Enpeemce. due to
Date

Page |

nehonk Cemgea hen )

Medie atu CemmnIcahom

the
Lneles channel Aon data
tsmafe behscem device metonh

Catgonea tytJireteas
Cm municaticon Medaa
liosted Pain Cable i
’_Shtei Conmdist1 inulated
Coppen wines toisted togethes o
Tcduce electomagneh. intefesence
Tapea: UTe (Uhc lde d Tuscstod Paz):
Ethenet LANS.

STP Cshelded Tutsted Pas:


cudditcnal ttstkeel
Jhieldna os cduced
ntesfevcnce

Cost-eifectve, wodely Ud, Aible.

Oisadvaataga Juiceptble to etermal mowe


Date |
Page |

Contina central Cemcueton.


Ctopen) onnouded
ndulahag Umetalleshieldy
Outen pnote chive COVes
Cable TU netan ki,
boadaam Intemet

dted
Ais called, lbeter Jhic lding
Doad vaatae to tued
hasdes
pas
to
Cables
natal)
Comparsed
)eOgt Cable
pulsea to tonmt
plaahe irea

Componcabon Ce ndenJea Cables .


3Multia-mode fbenCmm f): Shsst.
dotaree Communitaton (ey LAND
Cutremel elemagmehc
Jpeed tansmisfrcm
nttsfercnte
Date

Page |

to Insall
Dundvantases'
Om
Cupense,
mantan.

Wineles Comnumrahen Medua


Lcnele tsamil1on media do not
Ttqirt phyacal cables they
elec tsmmagomee avea to Otsamafex data
)Radio waeA
3 kHz to 300 GHz.
atHe
’Ued
mobile. mehOnkJ.

areal, uppont
mobli

secunita thrcat

sal Com munNcoatzo_cellolas


nehugonk(1a Sa
Aduaniagai Hglh dat tanam sates
Ing- itamce Commnrcaoy:

Commmrcahon affected weat


Condits
Date |
Page |

) fraed Waves

URemole. Comhaols slhont-rnge


wineleM Commumrcoatioy
Auahbaaai Hhreda data Secune does mot
J t others Jgaal
Diutguaaata Kesi dicct Odirect
lmrte

Deuce and Thesn fonctom


Netuonh. devices handat. devce
facilitate Comanrc atien beteem
Cosquten othe metnhed deicea:
dey

1) ModemModalaton - Demodulat)
’Convebe tom Com pules
nto nalog
me Lnea
tsanmisiom
telepe
heme metonk) to he inem

Modem Use telephmes lines


fog ntennet

i) Cable Moden - Ue coasa Cablea


Date

Page |

22Ctemet Case (Netuson Taletace Cane 9-NI)


’ Allo Commpule) to Connet to metuonk
oine Connecten

-Wined NIC: Uses am Cthermet cable CAI)


’WiseleA NIC (wi-fi care): Pouide

Deauts
3) RISCamecto n

to COnnect Etemet
CablenU to nehwonk device

’ Ha. that hsamit


dat
’ Used twrth tuisted pair cables fos netwonke
’Used Tn i LAN Connechrons oute,Switehes
amd

4)| Repeates
|’ Amplifes and Egemeat metn
eantemd Ahe tsa misorm

netwonh whee
ove long distamces
Dato |

Pago |

SHuß
device 4hat
Connets Vnulti ple C,omputer
LAN brodadcoUst data
ho all Connecte devicea

ypes ) Achue Hul: RequreA powes

i)lasire Hu Simoly comnecti devcea

netuwonks but
langely eplated Juitehea
A netonk
direct data
devce
to
that ntelliem
the Spe cifc
device meamt fon,
neooni
Atvamtay Reduea date colluios by
Sendng date cony to the
intcnded
Commaicatiom
Cimultameous
).

nh data Centel,
ce
LANsetvps
into
metoonha Wi-fi
toConnect to
emeables that acapteI
JeviceA
ica Vo?
onk). Bluetooth with
Cennech
ng potocol
9Catey metonk
different hajeen beLidy
acceA nemet fos
Bumes
Ccmnecbviy
wi Prourdes Routs ’releM
Cablea Ethesnet Usea Rostes wined
based pachetse data
eA
dsect Tutemet) the to
home nehoonk moltple Cmmecds ’
Page
|
Date
Date |

Page |

waf Adapler
device wcleM

’UsedGnixle Tahersmed access


fon coapulexy amd mandt devicea

#Nchah bund Netunk lyoes

K3) Penonal Area Nehn CPAN):


’A SmallnetonA fon
ithn CA

fe
Erasplesi BluctoctBl Cenechona
wisele headol1emastatehes

(Local Ata Net 9nk (LAN


’A netonk mall
heme

Cuample in

buineN:
3(the met Com neded Com pute
ofheen:
intecta
ultplc devicea
CmAN)

nehwonky
folle Lwri hot spot in Cihes

CoveI a larsg
CCmnetn mulhple
Vahes

Cospnale ndnks Commechng


nulhple ihes ox
olfres wonldrde.

aploges
Newos o the nngeneat
of deite, mctwnk
Date |
Paga

e) Bus
’All devices mected to a
cental Cable

Set u
em Cable

Dsndontaaa the Cable ail:.


emtre netnk
’ Peshename
evceA
decseaes
adde
’Used Tmi Small metwonks
Cthemet nehkJ.
Date

cevices Connect

central swrteh

to et
le cable.

the marr Cable tail,. the entr


doun
Perssegaate decreasEA devices

-Used nSmoll ofhee metoonk


earsl etheet netsonki

Hob
g Jts Comqartd
to Sehup ’Comple
afiected metuonk
enhrt the fels, backbene the
tanesDisadan ’
metwonks Scalable ’
izaion hesarchical,
organ Sopponti
Advomtaaea, ’
cne. backb
Comneckd
to nehonk
binahon Cem
lopalog ()Tre
Page
|
|Date
veA: mail to cliem teom emalmal eJemds ’
CimT otocol Tromsfeo Mal4)Somple
MetwoNh
Oves
ptees Com between ’Tsonfea
leA
(eTP) Psotocol Tsfes fle
3
Jecune.
TTRS) Jecure Rrotosal Trasfes Hypente 2)
intemet the we’Tncsfe
b
(HTIR)
eikucatly andaccunately Oyeceived
and tsasmted data CnJune
(hey
metunh
devicea loetweem
ules define. pnotocols Netuosk
notocol. Nehwonk
Page
|
Date
Date |
Page |

mail lesve
to C client

)Ponat to Ront Protocol


’Estalbl dhes iret Commnmmcahon lsehweem
t o metonk evices
?imimirn Control Phcol
Tutennet Potocal CTCe/L)
foundaton the intemet
date Semt,
adde

to anothes Commputer

4) Voce Ove Latemet RotcolUoI)


Cnables Cenmmicatie the
nteonet. Calls and Videa Conteremcng
mams cmAIn D ’ www:cm
(em ple
protoce| ht:l|’
web Complete lhe
(UR Locaton Reauate. )ifoom
websie
tadable humam ’lhe
Names Damain )
datatonspond
amd tone
(XmL
CXmM Languaag Maskup Geaclie 3)
web
cyeate to Jranda
CHTM
intemet the acceale
onnechedcntesc
Cwww) Wewte Wonld 13
Jesvites #nboduchon
Wel to
Page|
Date
Date |

Page |

Webutes
collecton o
deman

| AA sofhoane apllkcahon ied


acce webuitesChstmedye

3)Web rse Sever


A hosti Jebstea cnd
leves web to

A Jesysce that
to Lwebitea the
ntemet.
PAGE

Oatabase Management
#Relahonal DatabAheA
&odvben to Relatenal DatabaseA
)A relati enal datahae Jtones
tables (relati)th and
colmn

Ae-com mence Jocral media


entexpase appl1cahtad
School
hare tasles 1ine Stydent, CouneA, oud

Oatabae

thatnteract
oith 01e55, applicattmA, and databahe
to tone auad etoeve data

Cene'et
’ Data Oagauizatm Sto.nes data
mamnen.

Cmalei
ta
ble anotheo
fos sdembfe
data TepseAem
hag
table a eld AClolmn ’Aitole
table
rcond Snale CRowi ’uple
columns data
laked callechon
t (Talie:A Relatin ’
tablesCrelabema) into
Jata relatiena The
Codd Ef Dausloped
b
Model base Data
pplcatms
Sepanta
data Sepaatea depeadenee Data
avmm
mulple Allaw Jat acleM
to
Sbamng ’Data
tmaullhanize Reatac Serunty
i Data
PAGE
DATE
Database
databae based
Stsuctused

|’ Vca- Web applic.atms cata Locsehoujim

featunesi
’ fast and calable
Secune Cm plianle,
’ Cem patible Loith mina

Cstoycttd

databaeA
: database uatem that

Relatoma Data Model


’Relatoa Oata Mode
dat mto tabea (relatoa)
Lurdely Used Relatal
Databae
Studet Sthuden 10
Table. 401

E
Relatenal (odeli
4 Relaton (table)
Colmas
-> Cach iclaton
in the. dataase
2 tbute, Column)
An attabute.
clation Ctable)

Cranagle. table

attaibutea.

3Tuple CRau
’ A tugle.
rtpreaeat
table
Canmple ule

attiy e
bave
DATE_
PAGE

att'shy he Cam hare


ualues lheieen 16 to 30

5The
MumbeS
dearee gelatcm
atta butea Ceolun)
Ahe

table

bxample :he shdemts table ha 4


atts boteA c

6Candnaly
Casdinalihe reless to the nmben

Eromsple the
Hhen
Shiden
demt table has
Casdnality0
Relatcma Mode

Camdiate Ahat
idenhk
Shud emdO email
DATE
PAGE

Yin ke: A selectedcandidate.


key tlhat lenty

Altemae, kes :Can dhdate, Keys dlat


Onottelected the

tuse ism Men: An attabote tat gofesi


to
aanothen tabl
i Studenti table gteana
to CousC.ID CovsjeA teble.

StudentTable:
Student IO Name
l01 CIE 101
10 22 CCE 102

CowneA Table.
Covnsc_In CpK) Counse Nume
CSei01 Compute Sereme
EcE10L Clectsm
nsunge Manipulatn
Lanqunap Defniten (Data DDL
1nt divced
yaanta Ceahant Gafoncedat
élhcuentl data RekneuE ’
geconda delee' update nsen
tablen anddatabaes Cscate ’
datalbaAeA elatishal
lanaaoQ
C
Cstustned
telble
CouneA reescnang key, foneroh
the
table emt thwd the Counye
table Counsea the
Hhe
table Shodemt
he
FAGE
DATE
tudent DESCRI.RE
hovcte: table,
Uniae
INT,
NOLL, VARCHARs0)
NOT Noace
KfY,PRIMAKI StudemtID
TNT
shdemt table Cneate
tablei Cseate
a
databaeAj shok
databanen! all Show
databasei
School; base data Caeate.
seate
esCRIRE SHOL)
DefuhmLaga UJE DROP CAEATE,
ADatoa
PAGE
DATE.
DATE
PAGE

Alteo a ta ble
Colm'
ALTER TORLE _shdents Aoo COLUMN
Adse VARcHAR C2ssi
" Remot a Colwmni
ALTER TABLE tudents RopcoLUmN
Addsdi

pomag.Shudenty ADo PRIMARY


KEY Cstudemt. ILO;

ALTERTABLE Othudet DRof


PRIMARY
" Dauo Table (Oelete Table com,pletl
DRoP TABLE hudent
.

Daop Database
op
DROP DATA SASE Sebooki
DATE
PAGE

aipulaton.
eRE INSERT SELECT, VRDATE DELETE
Laent data
ceta nto table
aseRT TTO Sthdenti Cshudents In ,Nat.,.
Asp., Cmaik) VALWEJ CloL,Rai' 2,
raCamat.<cam')i
"Retiee all
SELECT fROM
" Retnese Speckc Calmmd
SELECT Name, A fROM hodent
"Update Data
UeOATE shodemts =22 wHERE
StudentIn =I01;
Deleke
OELE TE fROM shdemts wHCAE ShudeatIn o
DATE
PAGE

Data in

CHAR (m)’ hncd Lonth (n chaacters)


VARCHARC) ’ Vaoable.Mengthtes Cupto n
Chasactecas)

LLOAT’ Oecmal humhex


DATE Stone datavalues
data

*Cosant
NOT NULL >Emne a colmn Cannotla
have NULL value
valuea Colmn

RRIMAR KEY Unispel rdenhhes each toow


foREIhN KeY Linky Columa to amothe
tasle's

Caample CREATE TA SLE Pessm


NOT ANULL
Last ane varchas(2rs) AOT NOLL
FizatName Vanclar (255) VNIQUE,
DATE
PAGE

’ Mathematical Openatsns
Addston
Jubtsachon
Molbplicahen

’ Relatenal Openatond
Eaual to
Not Capal to
Cucaters Hham
Lem tlacm
Chreaters than
Len tham eapal to

Rehunwa ttrue lboth

at least
Cenditon
NOT the Cendrhen:
PAG

mame
Alasreng tcmpon
ta ble colemn

SELECT Name Jhvdetame fRm studetl;


’Dishnt Clause.(semove dupicate vaues)
SELECT OISTINCT Counle fROm Studeati3
"wHCRE Clause lte xcconds baed
Comdtm)

SELECT * CROM Stodent wHERE Aae. >20,


CLAUSE Cchec aalue
SCLECT LJHERE CoynIe

BETWECN ClavseCselects valuea withn

SELECT fROm studemts lwHCRE Aae


BeTWEEN AN 2s;

ORDER BY GLAUSE Ciosts


cendng
SELCCT fROm Shudem OROER BY NAME
DATE
PAGE

"NDLL me
meaMA the value mknOwn
milina
SELECT Studemt LUHER mai
NULL
fROM Shudeni wHERE Email
NOT NULL;

:LIKE curth
lause CPatenn matbhina)
amben o chanacean
Characles )

SELECT fROmn hedents JHERE Name


y ames

SELECT EROm SdemtswHERE Name

stastna witt R
chasactes

SELECT EROm JhdemtwHERe


Jhdem Vame

stas with
mothing
Contan A, a hasatesy
H.
Cam end w th
aythg
fmchens
MAx< ’ RetyDm the mam valve
MIN()

SUmo
CoUNTO Rethn he
3ELECT cOUNOT (+) fROM studemto i
SELECT () ShudemtJ;
omd HAVTNG Clause

data lbaed colmn:


HAVINaflteas
SELECT Coune COUNT C*) fROM Jbudemti
Coune

SELECT Coune COUNT (*) FROmShudemt


Coune HAVTNa cOUNT (*)>S
Jons Cemnbine data «ors aulh ple
CARTESIAN JOLN Retns all poule
combineatis

Condits
Colmns
NATURAL ToLN ’ Aotmahcally ions tables
based Cormn Colym

Casteam
Castaran prodct Lwhem
each fisst table
Cembined 4he
Secomd table

table A has
has the Lave
X m

Jata set Ualesfiltesed nneeeA Lange


wHCAE clawse
DATE
PAGE

Talte
2
3

Svdent table.
Studend10 Name
Ray
" Coun ses table
CouneIS Coune Name
.101
402

SEECT fR0Mihdenti, CounieA


hodemtCounieA
ShlentID Name Coose_Name
Raj
Raj
2
DATE
AGE

Tnes Jon
thal wmatcheA gcconds ing
Colmn

TtoiC.VeA. nly ynatching

Shdent table
JtudemtID Counse_IO
Name
Ra 401
2 102

" Coonse tasle,


CousasID Cou seName
401
10

SELECTshudemt.Name Coue. CousieName


EROm shdemt
soTN Counes

Nane CounyeName
Ro
CATE,
FAGE

"Nabaal Jom
’ANehnal Toin autom atecally oin
table based

eat the
Colmn:

Cxamale
SELECT Name, Counc Name
fROmshodenti Nathonal T0IN Cou.nsesi
Name Coune_Nane
Rai

ame ?

mn

JTUDENTI JOIN
Counves ON

Studet IN NameCasie Ti) CouJene


i01 101
102 102

CounseIO Appean hoo hnea hecaue bat


table CUntaun mean

all colnm
clas mate.
Date
Page

’Castearam rnodvct Matehe eve


loith
tsm able B eve
Eai Join Mathe
mdithom.
Conditn

’ Nahsal- doin ? Automatcaby jains toa bles


colms namei am
duplicae. Colmna
cssMate
Dcie
Poge.

with datasase

ttalline Packa
initall
pip 1tall

Ceonnect

mpont mysed Comecton


(host =localhort
laatabase ophonal
Connected

Cunsanexecute Create databae test 123


n0F
Cunon-enecute C Create database
ecuteCUje est123")

directle to database
@Conmechng
1mpont m :connectn
hot localaolt
at paswd toen' databae 'teat1?")
classmate
Date
Page

(neate Tmsent mto tuble wirtt

Jampde
CCneate táble
Mame VARCHARCo),
Jample tav colon VARCHAR Co
)! )
Asnt (( Table ceated)
pant
Indent i'nto Secon
fav-colon) valires(1 Davsta
Jeit, Iusq,uaiie (2Lelia Uiq ran'Biu)
(3,Susaan Ponsfondcnmda " )
I/ Lmpontamt to commt
pit CData Cnses ted)

Sample 3
IO:"))
pot CEnter
nput (Gatex
: ")
Colon:")
goun fauOUnte
Cunso) Cnecute isent int
favcolon valves 7S, 7 , Y-s)Cid, name,colo D

Cusloneeet tcons Cid nam


favcolos) Vale (s.3.3)" fon mat Cud,maey
Colon))
classMate
Date
Page

*felch data fom database (Geteh Al, feth Many, feteh Oe


RowloUmt
impont my(onnec.tan
Cen nectos. connect Ch ost localhost
Qsen Tootpastwetoon'atabase eati3 )

y ata = cUnson. fetehall

my Data Cunson-fetch many


mo imo:
paint CmyData
past Ceen myData=
Ceunson.0WGOnt
hyD:cdoe IL Tnpsntamt to close.

D at a thme Rom the

Re taeeo upto
etehadl
Retaevea all rtmainnag Ycerea
0weOunt
Retvom nnbes ct Ow) afPected last

You might also like