0 ratings0% found this document useful (0 votes) 102 views14 pagesMySql Notes
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
ny SQL f= Ghaclured Query language
- y
Data — Wi distinct pieces of Infommatien, or Collection Of
facts Sielated lo any entity.
will be Stored:
nates
Daibace =< Giply a Container where all-the dato
6
Database Management Sykes z- A Cettectton OF pqs which &
Use -o access database, manipulate data and Aepresene doka-
Types OF Matabase Management Sysune (pams) t—
Revered
Bn Order tw handle Aue data. we Ose pic DEME Te TE“
Lind’ — are © Hperarchied DEMS = @ network, DAMS
@D Relabonad DAME &® Object _oniented DEM
chil relationship > Stove
Hierarchical DAME &~ Te is o parent
re a0
Data, and Srusure ke atree with node epee cen elt a
branches repre sentig feids-
network, DAMS g- tk Ruppert many —
Qrrwabere-
4p - Many Te toctiors.
pic resulte 16 Cemplex data base
Relationol PBME st efinee database rattuon Ship io-fom of
Fables, also knacn at (lotion, TOW aNd Colum repracrete if
data iknow ae -table- where Veaticad represents? known as.
Scanned with CamScannereld and hotizantal reprecentation yo record. Common -fietdc
So table represent Prekkon between wo Taber
Objent —Onented DAME 7- Thic “Hope Lapports Drorage of pew
ate typec, tu cata Stored Snfam of Object:
Sacked Quin large ESO) Tete &
iy Lica Standand, Preamenny) es 1c Ux0ed for eatia
felakional Databases.
it) With Gat we can modify databatec, add, update oF dele
He.
aq base and any Me
re TOWS
OF data. , re tive Qubcete of Iforrotion fiom a dat
Qu, Arex red sheet ate
Wi) Relodrenal Pala bases like oracle, MY
Are Used SOL
WV Qoaniet awd Other Sql Opendlione are
ax Seteut “insert, add, opcots, delete, Crea alter
unitten aS Catemente
toruncdt:
My S@L z- |e a relational Catabate Managemen Syste
n-Sounce Software, which poids muti Ure access
x FH is an Ope
ard woaks on) OMY plotfcwne
and %4S Sopporte mutt Oe Crginer
My SQ@u Wwlork bench g- A ie a yicua) daabate- designing and
modelling acces¢ —fool for my sae over felational cata hate.
Whee wedo modelug ef database, Gal Development
‘Scanned with CamScannerSQL Command Colegoriee § —
1) Pata Defination ee ae (ppc)
> Data Manipuiction horguage. (DML)
3) Pata Cento Fong tage Ope
v) Tran caction Control Language Gna)
) POL ge Concist Of Cmmandk that can be Used 40 define ue
database Schema
Ex: Create, rop, -OETER, TRUNCATE, COMMENT, RENAME
2 DML e— the Sql Canmonds tok deals With ths erooipuloti ofits
Present in Catabace.
Ex : SELECT, INSERT, UPDATE, DELETE
2) DCL t— Include Commands which roalinly stele dealt uit the Tepte
Permnricsiont and Other Contals of ue dato bare Lytn-
Ex: GRANT, (NVOKE
a 5 -trancactior)
By Te g— TWe Conmancli which rainy ec with The
of Patahase-
Ex - Commit, Roll Back, SAvEpoINT, SET TRANSACTION.
Data Modeting 2— st ic Dolaca bu decisning of Data. where.
we design by © Nloimalize Sata hace
@ Entry — Relattienchp Digye™
‘Scanned with CamScannerKum BOG — iysteamporrzD_— xa AMIN
Luar 2H ‘aa 4 ; 1 t
|
| Peed 4uN20NId90, |
xT
“\uoraM) |
Ww
sum Fy warsiiadas 3
NY
\ mpd
“nad ansinsndng)
v ey ee v
pRNERRG oe, Perales aie on oA 2IAOTAIE |
“425
laqe207 Aqua ; | 0ST
IN
UO P yos mom Lu cour LD
By py 2004
=: uals (y=) dupuompory — hyo
‘Scanned with CamScanneri) From Hue chiggramy we can Gay -Enitice ae. _ Employer C
Department , Prgect, Dependuncunr
ty There ave relationshipe built in between entity Ff we Observe .
FO between employee and department. there twoakefer ic One reloten
and er Fe anol relowtion: Qimilaaly in betweed Depaatmenk ond
& Cortrole ic relodion , inbetween employee and project wolecn
Project
FO between employee Ad dtpercint Depordunk-<
is (elation —finodly
ie felattonships.
liv) There dependint entity
employee ennty (When ever wy entity i
_ entity) imilonly Project entity icalse
relatonship betwee")
ie weak entity becaue it Atpercl om
¢ depends on Otber Sa
os enHty.
Called as Weal weak, +.
iw) where employee entity ic Steg entity the
ec Wek Relstienship"
Sey entity “0 weak entity i¢ alway
or MORAL
p between wo oer emhtt2e
wy Qimilarty if relakonshi
ew Projset ys aluaye
like ennployee to Dependement (on) employe
* Sreng telatien hip”
Vv) ucbere® Sey Retateenrchip"
lwr rota ship known a
rojo Te a Contiol type Relaten chip.
Cceunec when an employee hin cetf employee
live , Bose and WO Supervisor)
vi) finaly dapoiment Contle f:
‘Scanned with CamScannerEntity § Vee-Odnbulit ¢— ¢
E E-Q] Program Consist of many athibulc a8 chan 1n-fjcurey
Tay awe — 9 Corposte atibulie 9) Simple -AHribultt
8) Aigte. uw) MUMIple valued Glored 6) Derived
> Comps —AHnbultt
+P) Composite attribwle canbe devided
Composite ve Simple—HHtnbules S—
Gndlivictuad Basie. struts
Toto Conley Qubpaate jthece Qubbpoake Hepes
With dbair Own reat
where atinbulee which i not duvisible ae Simply know OA Srp €
automatic Attribuloc.
- a pe Nwmber 7 él
Ex ; _Gueet dress —__, hy cee if Gimple Per
Adress > city youre Numloer
ai > Compoute SHnbutte
“Zip !
@ Sine ve multivalued -Oftabutte 2 pH ribetse bourg Grog: vast -for
OQ. Pantiewlow entity ic known as Sings valued adtnbutes.
obiibute aray howe lever and ofper
fry each individual eotity.
bounds to Conshoin
Ip gyubtivolued
Mie Qumber of vous allaved
® Glored ve derived Ori bude 6 - “a Shaved atfribudec Which aie. already
Glored Go the database. and omy which We value of molar attribute
te derived ic called foe atnbute -
‘Scanned with CamScanner_Otinbuler which ae durived fim te real entities a
Gre known ac derived dr buee. -
=x
s
nikdate § Store:
{ Dewved Birkdate { Stored Dui bult F
Age
Inf E-Rj Diego nto Of -employecr { Repretent in dot lioee} te One type oF
Derived atin butt.
Thee attnbutes Depresent br Geosting Composite
1h Cones 04 Me
cu O4 Compe OF
Conmplex tribal ee
axributer between 0, Lepanating fie. Componente wil
cLetplaying luc ruttivalucd oFhibulle between FJ are ko
Ex: f_Barece- phene (§phone (Area Cece, pme-nuumbea),
_Davece ( Greet - advese { Nuorbur, rect, flat. ltumbe?, aby, Sted, xip))F
Enkiy Tope, ake kaye foie SES
ently 7 Employee Cempany
Entity DRS 7 Nlame,-Ase, Solon Name, Heed Quatre Cuner
el Fi
Entity Gene Sap Hpk _pmaxcn, nrewyeah, Orde
e2 oe:
miavsoft, Dia, kanav
amect, 24 ABK
+ values entree *0 ephity Cote QSe- Called as value Gate fn 20g
orecrd tore Te dafyrent valuct Oe eniued -
‘Scanned with CamScannerDilferent Tope of Mage 9 Relational Oodehase :— @
at ah aie 2) Super hey “i
Be (eaern Key 1) -Clterals bey 9 Foreign ny
Candidate bey eis baocally Q minimal Set cf attributes Which Can
Uniquely “clenhfy upland not null Ualue present init. QomeHunes
Candidate key alco a pomary koy
Soper lay z- Super bay ato a One bind Of Comdicale bey here.
sy ts.
a ovomal Gt of atnbuter which Gn oma iduntify a. tuple eg
gat wh con Be wel
Primary lay ¢— 4p ic alu a Gt
Corey ‘ean evry ple
There Cam be mose tion On
ore Canbe Chasen % pnivaay "24
ais oy 9 an 0. rotation Cur 4 wbrch
ny boy # Colts
lternabe kay ¢~ Concuctete 4 iper tho PN?
oltemade, AY Farehicse-
c f son ciate Con any Sate BS Egan
aot abide, 1h vill prasieally be e195
Glo A
present os vous 9 Ore
Yay to we cbtribule ahr
Refereed atinlede 7 rafnerys
primary tay
%t Hef’
Scanned with CamScannerae A Mae re Ee (¢
Emp-ID | EMP-NAME— puone
STATE Tenenre lage |
| .
+ | AMEER ——S31905q | Telange, Tndia 2s
ae -AMEER 1654120 Avdhia Tagine
3 SAMEER £43465) Delhi = uaa | 26
4 SAMEENA = FBq4850\ Mabarasha -Pudia 2\
F EMPLOYEE Dept CT-2)_
EMP-1) | DEPT-NU) Dept-NomMe
) Dl TECH |
SE D2 MARKETING
) Des MARKETING
fiom —Atbove two dablee Cri, ta) We can Gay cempn?,
4 tupk @
EMP NOME, PHONE NO beni Cniquely davidec) while
Individually {tic Columne we can Say Caraidade ber.
“ePrecent
from above mentioned Cotumne of table! Ceand dat hay) FP
yy cet Celumne ubich clavicle whole -luple 1 Called AX Koper bey.
i h we mentioned U fir Coondiclote boy tap
it fu Columns whic eI :
Gimitony present on Ong uly felle
fh hewe 0 mull value
mony boy.
L
if we Chote Emp-10 a pamany Hey,
tat Whe Column whic!
Hae whole pte '¢ Called ab PP
Ctr thon thie bye -forsGuppore
Emp-ngame as Condictode bey,
atenate key which 1¢ Onsucly
whole tole.
paibing represent
dwide
Prone NO Fen
identified and Gmilerly
‘Scanned with CamScannerAinaty if We Make felatwn jn belWeen “Table Land x “|
by alay is Called a —Foreyn key are that should be @ Prmsvy
follee (Emp-tn)'s ate. Primary kaye in hoth tables
bey , fem We @hreve
rumbers and thie
amd make Gelatin Between lump 4 Gefen eng
eprecent whole record 49 table?
Normattzaitiey 1— He is a/ lechnique that Opemines fables 70
Quinta way hat Srecutiney andl dapenolsney of data ic Heduced-
Bene fAoYCe - Codd ‘Alormal form }
yANF
\\f/
\\C a Ne
NG
Here we jut mele tus date: by nenmalization forms lune abe.
) where dala
\
J INF
—feur Aypex 3 fame Caled as INE, ONF, 3NF, BCNF
will be neamalized at amy Ore ef fom Inhally af INE we
if not geust-lo Aiat fom 8
ims. Suh that Orgpnne atable
Ip, due we
deta will & nomalined. cur. 4
ust Increasing; tue level OF romal -fa
So a well monner
CQL Aiibute Data Mpc — Classified ac_
OE ea
) Numeric — INT, FEOOT, Reet, DEcimaL Ci,j>
2) charaeb - String — caren), VARCHAR CH , CLOB
‘Scanned with CamScannerRBit-STRING — BIT (ny, VARYINGCn)
3)
kh) Boolean — TRUE, FALSE, Onknown "s
BY Pate-format — Oate ¢ Time
6) Time Stamp -
Contrainte 2— In Simple tume
Hie ase ue Guter thak Combe applied
en te inne 4 data Fo a -lable-
CTC enc tnv aa Can) ee czrc mic Columns.
ONtQLE — AN tle value in a Column are lefferem-
CHECK — Al) tue valuet i a Clann Gousha. Goce) Coreen
DEFALLT — cet Ff cLefault valus—for Colum voben Ob vats i¢ Gruified
INDEX — pie Censhain UOced Ww Create and retnve data fem
Mu Databace Very quickly.
SQL — Commowat_ 2—
ae
Create an Index —for a table.
Modify actable Cadd, modifies, or del
CREATE (NDEX ¢
cet athibutte)
OUTER THRLE ¢
Deop THeLE + Perminently dlolete a “Table
CREBTE SCHEME 2 Create Datahace SKhenya
PHOTHORIZATION
* Create 0 newbie. fo Osers Data bace Schema
Column will not have a Mult Value.
duplicate valuce
Creme TOBLE
NioT NOLL 3
Column will nok hove &
Definee a Prony lay fr a “table.
primary key *
Foren key ¢ Defines a prety hey for a Tobe
Scanned with CamScanner
ONI QUEDEFAULT 2 Defines a default Valus—fo a Column eo
2)
CHECK < Constraint Cred lo validale Aafa in a cltibute — _
Drop Vieu! ¢ Parminently clelelec @ Ws
Deop (INDEX ; Perminently aeleteca lndex
Mose.
ace ee nM ica dynamic Barset 41048 [eatwame fron men
~poblet.
Create new tobe ante Usenc data-
re
CREATE TABLE Ace Ve qed
— pare S
S@L = Data Manipulatien Commantt é-
One co mole fables rows
Oppate : Modify an adtnbutes valus f
Commit = Peminently wee data coe
Insert ¢ Inceak towcs Tiny able
2 Select tribute fre revs ci Oe
Cecect
Here + Resticts tha Sdetien er rove based 07 @ Corditfenc)
-Capression,
Giup By 2 Gioupethe eledsd rows bated on Ore or MOM atfribectec
HAVING 2 Rectnct the Celection of Quped rows hated On
Condition:
ener By & Crderstec Solerte! Roux Phased 61) One or mose cfributes
perete +: Delete Cre ex mone Howe from a-table
ROLL BACK ; Restore olata to -lhety Orginal ales.
Logeas Operedtore = AND | oR | NOT
Componsien Cperotoe ¢ Sh =) re Sr
‘Scanned with CamScannerDESrigne -(unetione ¢ — COONIT, Miart, MAX, SUM, ave @
Gpecied Gperctors 2 BETUIEEN,, (CNIOLL, LIKE, IM, Exists, DISTINCT
REV WEEN =¢ Checks whether an aHribute Value is wilh ina lag
Lime + checks whether om osfribule value maces guen Grins paler
IN s Checke u soy nt ay value with ty avalu list.
it
Exerc 4 Cheek ulbether a Subquny neteame oy H!
e
pictincr ; Limits unluse fo Onigua unlit
Relationad Dlegbra $ Relabenal Glatt §
eee ene ONLI SUSE Cera
Lpany Relatrnal Operate ¢-
) Glect Cperetion 2) Prgject. Cpe ration)
2) Rename operate)
fen
Golect cpination ¢ FE 1 Osed to Cheose a Subset 9 aa
reloctiog that Souicty a Selection Concston-
disCards
Project Operation ¢ Select Cestainy Column —fem the “oble and Os
lta Ctber Columns.
Rename Operate : ic a Coary operot oy Used as ali butte z
Aa velatinn.
Cet Cpeotionn ¢— ule awe different lund Of Getopnateme Qie-
Present. “they ase — ( OMion Operation
@® Inlercect Cpacation @ Minus Or) Excepr Operas
( Cattesian (Crose pratutt) Opercica)-
‘Scanned with CamScannerY
ei! Right Query Final Rerute
eS aa ail uf
\) \ ) ONION \ ) => Combine rane fier)
— = SHH YY both ue Quuniec
Keeps enly thece Mews which
ase Comme in beth he
Quines
2) Intersect ay \ )
ee a |
3) =
Minus UU \ = Weepe yews-fem ths laf Gunny
~ =a = which ate not included 4 tue
Coss proctuut Operotion :— apr Query
i jhute
Chose product between 2 Gelatent (448) wil] Houle GA Ate aatfribube 9
‘4 'filtewed by each AHnibute qB: ach Hetord 9 2A’ wit be Pair with
every Gecad ‘Bl
a AXB
- . i at Dept
= Name Age Sex ID Dept Name Ae Sx In Dep
. | Tech Amer 26 mM 1 Teh
Amery 26 Mj ae eer saron
Raw ay M7 2 Edam Oe Sy ag | Ted
Gummy 27? Ren 24 M8 Edu
Guormy oy F |! Teh
Gumny 27 FX edu
‘Scanned with CamScanner