You are on page 1of 4

u8MS ConcepLs

uaLabase
A daLabase may be deflned as a collecLlon of lnLerrelaLed daLa sLored LogeLher Lo serve mulLlple
appllcaLlons
Lxamples of daLabases could be uaLabase for LducaLlonal lnsLlLuLe or a 8ank Llbrary 8allway
8eservaLlon sysLem eLc
uaLabase managemenL sysLem
A u8MS (daLabase managemenL sysLem) refers Lo sofLware LhaL ls responslble for sLorlng malnLalnlng
and uLlllzlng daLabases A daLabase along wlLh a u8MS ls referred Lo as daLabase sysLem
AdvanLages of daLabase sysLem
uaLabases reduce Lhe daLa redundancy Lo a large exLenL
uaLabases can conLrol daLa lnconslsLency Lo a large exLenL
uaLabases faclllLaLe sharlng of daLa
uaLabases enforce sLandards
uaLabases can ensure daLa securlLy
lnLegrlLy can be malnLalned Lhrough daLabases

8u8MS 8u8MS sLands for 8elaLlonal uaLabase ManagemenL SysLem ln a relaLlonal daLa model Lhe
daLa ls organlzed lnLo Lables (le 8ows and Columns) 1hese Lables are called 8elaLlons
u8A erson who deslgns Lhe daLabase and wrlLes daLabase schema ln uuL based on Lhe deslgn
8elaLlon A relaLlon ls a Lable le daLa arranged ln rows and columns uaLa musL be aLomlc ln a cell all
rows of a Lable are dlsLlncL orderlng of rows and columns ls lmmaLerlal
uomaln 1hls ls a pool of values from whlch Lhe acLual values appearlng ln a glven column are drawn
1uple A row of a relaLlon ls generally called a Luple
ALLrlbuLe A column of a relaLlon ls generally referred Lo as an aLLrlbuLe
uegree 1hls refers Lo number of aLLrlbuLes ln a relaLlon
CardlnallLy 1hls refers Lo Lhe number of Luples ln a relaLlon
vlew lL ls a vlrLual Lable LhaL does noL really exlsL ln lLs own rlghL buL ls lnsLead derlved from one or
more underlylng Lable(s)
rlmary key 1hls refers Lo one or more aLLrlbuLes LhaL can unlquely ldenLlfy Luples wlLhln Lhe relaLlon
lor example Admlsslon number ln Lhe SLudenL 1able Lmployee ld of an employee ln Lhe Lmployee
1able lLem number of an lLem ln Lhe SLock Lable eLc A Lable may have more Lhan one candldaLe keys
buL only one prlmary key
CandldaLe key All aLLrlbuLe comblnaLlons lnslde a relaLlon LhaL can serve as prlmary key are candldaLe
keys as Lhese are candldaLes for prlmary key poslLlon A relation can have multiple candidate keys.
AlLernaLe key A candldaLe key LhaL ls noL a prlmary key ls called an alLernaLe key
lorelgn key A nonkey aLLrlbuLe whose values are derlved from Lhe prlmary key of some oLher Lable ls
known as forelgn key ln lLs currenL Lable
8eferenLlal lnLegrlLy
8eferenLlal lnLegrlLy ls a sysLem of rules LhaL a u8MS uses Lo ensure LhaL relaLlonshlps beLween records
ln relaLed Lables are valld and Lhe users don'L accldenLally deleLe or change relaLed daLa

When referenLlal lnLegrlLy ls enforced you musL observe Lhe followlng rules
?ou can'L enLer a value ln Lhe forelgn key fleld whlch doesn'L exlsL ln Lhe prlmary key of Lhe prlmary
Lable Powever you can enLer a null value ln Lhe forelgn key
?ou can'L deleLe a record from Lhe prlmary Lable lf maLchlng records exlsL ln a relaLed Lable
?ou can'L change a prlmary key value ln Lhe prlmary Lable lf LhaL record has relaLed records

uaLa lnLegrlLy 1hls means LhaL Lhe daLa conLalned ln SCL ls boLh accuraLe and conslsLenL
MySCL MySCL ls a freely avallable open source 8elaLlonal uaLabase ManagemenL SysLem (8u8MS) LhaL
uses sLrucLured query language(SCL) MySCL provldes a rlch seL of feaLures LhaL supporL a secure
envlronmenL for sLorlng malnLalnlng and accesslng daLa
MySCL operaLes uslng cllenL/server archlLecLure where Lhe server runs on Lhe machlne conLalnlng Lhe
daLabases and cllenLs connecL Lo Lhe server over a neLwork
1he Server llsLens for cllenL requesLs comlng ln over Lhe neLwork and accesses daLabase conLenLs
accordlng Lo Lhose requesLs and provldes LhaL Lo Lhe cllenLs
CllenLs are programs LhaL connecL Lo Lhe daLabase server and lssue querles ln a prespeclfled formaL
1he cllenL program may conLacL Lhe server programmaLlcally or manually
SCL SCL (sLrucLured query language) ls a seL of commands LhaL enables you Lo creaLe and operaLe on
relaLlonal daLabases usage of SCL has become sLandard for mosL of 8u8MSs
SCL provldes many dlfferenL Lypes of commands used for dlfferenL purposes SCL commands can be
malnly dlvlded lnLo followlng caLegorles
uaLa ueflnlLlon Language 1he uuL commands allow you Lo perform Lasks relaLed Lo daLa deflnlLlon eg
CreaLe alLer and drop
CranLlng and revoklng prlvlleges and roles
uaLa ManlpulaLlon Language 1he uML commands allow you Lo perform daLa manlpulaLlon on daLa
sLored ln Lhe daLabase eg lnserL deleLe and updaLe
1ransacLlon ConLrol Language (1CL) commands commands LhaL allow you Lo manage and conLrol
LransacLlons

ulfferenL daLa models
uaLa Model ls a way by whlch daLa sLrucLures and Lhelr relaLlonshlps are analyzed
1he 8elaLlonal uaLa Model
ln relaLlonal daLa model Lhe daLa and Lhelr relaLlonshlp ls organlzed lnLo Lables (le rows and columns)
1hese Lables are called relaLlons
neLwork Model
1he neLwork model represenLs daLa by collecLlons of records and relaLlonshlps among daLa are
represenLed by llnks whlch can be vlewed as polnLers 1he records ln Lhe daLabase are organlzed as
collecLlon of arblLrary graphs
Plerarchlcal Model
1he hlerarchlcal model ls slmllar Lo Lhe neLwork model ln Lhe sense LhaL daLa and relaLlonshlps among
daLa are represenLed by records and llnks respecLlvely lL dlffers from Lhe neLwork model ln LhaL Lhe
records are organlzed as collecLlon of Lrees raLher Lhan arblLrary graphs
ulfference beLween char and varchar daLaLype
1he CPA8 daLaLype speclfles a flxed lengLh characLer sLrlng lf a value ls shorLer Lhan Lhe speclfled
lengLh Lhen blanks are added buL Lhe slze of value remalns n byLes
vA8CPA8 speclfles a varlable lengLh characLer sLrlng When a column ls glven daLaLype as vA8CPA8(n)
Lhen Lhe maxlmum slze a value can have ls n byLes Lach value LhaL ls sLored ln Lhls column sLores
exacLly as you speclfy lL le no blanks are added lf Lhe lengLh ls shorLer Lhan maxlmum lengLh n
null values
null ls used when Lhe acLual value ls noL or when a value wlll noL be meanlngful nulls can appear ln
columns of any daLa Lype provlded Lhey are noL resLrlcLed by nC1 nuLL or 8lMA8? kL? consLralnLs
CommonIy used MySQL Data Types
very column (or data item) should belong to a unique domain (known as data type). These
data types help to describe the kind of information a particular column holds. MySQL supports
the ANS SQL data types. Some of the commonly used data types along with their
characteristics are as follows:
CIass Data Type Description Format ExampIe
Text CHAR(size) A fixed-length string
between 1
and 255 characters in length
right-padded with spaces to
the
specified length when
stored.
Values must be enclosed in
single quotes or double
quotes.
CHAR(size) 'Maths'
'TexT'





VARCHAR(size) A variable-length string
between 1 and 255
characters
in length; for example
VARCHAR(25).
Values must be enclosed in
single quotes or double
quotes.
VARCHAR
(size)
'Computer'
'Me and u'




NUMRC DCMAL(p,s) t can represent number with
or without the fractional part.
The
size argument has two parts
:
precision and scale.
Precision
(p) indicates the number of
significant digits and scale
(s)maximum number of
digits to the right of the
decimal point.
Number(p,s) 17.32

NT t is used for storing integer
values
NT

345
date DAT t represents the date
including day, month and
year between 1000-01-01
and 9999-12-31
YYYY-MM-DD


2009-07-02

You might also like