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

01 RIO Understanding SQL

ANSI SQL provides an introduction to relational databases and SQL. It discusses key concepts such as DBMS, data models, database normalization forms including 1NF, 2NF and 3NF, and SQL. The objectives are to define DBMS, relational DBMS, database formalization, and SQL. Formalizing databases into normalization forms reduces data redundancy and inconsistencies. [/SUMMARY]
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views

01 RIO Understanding SQL

ANSI SQL provides an introduction to relational databases and SQL. It discusses key concepts such as DBMS, data models, database normalization forms including 1NF, 2NF and 3NF, and SQL. The objectives are to define DBMS, relational DBMS, database formalization, and SQL. Formalizing databases into normalization forms reduces data redundancy and inconsistencies. [/SUMMARY]
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 35

ANSI SQL

Understanding SQL

LEVEL LEARNER

Icons Used

Hands-on Exercise

Reference

Questions

Points To Ponder

Coding Standards
2

Lend A Hand

Summary

Test Your Understanding

Overview

Understanding A!S" SQL session #ro$ides %no&'edge and understanding of Re'ationa' (ata)ase *anagement System+ !orma'i,ation+ and A!S" SQL-

Objectives
At t.e end of t.is session+ you &i'' )e a)'e to/ (efine (ata)ase *anagement System 0(1*S2 Reca'' t.e conce#t t.at a de$e'o#er needs to .a$e+ to &or% &it. it (efine (ata)ase 0(12 (escri)e (ata *ode' (efine Re'ationa' (ata)ase *anagement System 0R(1*S2 (escri)e (ata)ase !orma'i,ation (efine Structured Query Language 0SQL2

Introduction
After 'earning Programming 4undamenta's+ you mig.t .a$e encountered a need to retain t.e data &.ic. is in#ut+ mani#u'ated+ and dis#'ayed )y your codeProgram mani#u'ates data in RA* &.ic. is $o'ati'e storageQuestion: What if you need to refer to this data later? Ans/ Yes+ you can do itQuestion: How can you achieve this data persistence? Ans/ Usua''y a'' a##'ications+ direct'y or indirect'y+ are connected to one or more #ersistent storage de$ices 'i%e Hard (is% (ri$e 0H((2+ 4'as. (ri$es+ 5#tica' (is%+ and *emory CardsT.is im#'ies t.at t.e a##'ications .a$e mo)i'ity to store data in $arious storage units or de$icesQuestion: How will you e a le to !anipulate and retrieve this stored data? Ans/ T.is is t.e 6o) of a (1*S too'- Let7s %no& a)out t.e too' in detai'-

What is DBMS?

"ata ase #"$% A data)ase is a co''ection of 'ogica''y re'ated data "t is used to searc. data to ans&er 9ueries A data)ase may )e designed for )atc. #rocessing+ rea' time #rocessing+ or on'ine #rocessing-

"ata ase &ana'e!ent (yste! #"$&(% (ata)ase *anagement System is a set of soft&are or #rograms t.at ena)'es storing+ modifying+ and extracting information from a data)ase "t a'so #ro$ide users &it. too's to add+ de'ete+ access+ modify+ and ana'y,e data stored in one 'ocation A grou# can access t.e data )y using 9uery and re#orting too's t.at are #art of t.e (1*S+ or )y using a##'ication #rograms s#ecifica''y &ritten to access t.e data-

Data Models

Ho& are t.e data mode'ed or structured in (1*S; To ans&er t.is+ 'et us understand t.e conce#t of (ata *ode's-

A (ata *ode' is a re#resentation of a rea' &or'd situation a)out &.ic. data is to )e co''ected and stored in a data)ase- A data mode' de#icts t.e dataf'o& and 'ogica' interre'ations.i# among different data e'ements-

<

Types of Data Models

Types of Data Models !ontd"#

>

Object$based %o&ical Models

) *ect+ ased Lo'ical &odels: T.ey descri)e data at conce#tua' and $ie& 'e$e's-

T.e E-R *ode'/ T.e Entity-Re'ations.i# mode' is )ased on a #erce#tion of t.e &or'd as a co''ection of )asic o)6ects 0entities2 and re'ations.i#s among t.ese o)6ects-

?@

'ecord$based %o&ical Models


Record+ ased Lo'ical &odels: Un'i%e o)6ect-oriented mode's+ t.is is used to/ S#ecify o$era'' 'ogica' structure of t.e data)ase+ and Pro$ide a .ig.-'e$e' descri#tion of t.e im#'ementation As t.e name im#'ies+ in t.is mode' t.e data)ase is structured in fixed-format records of se$era' ty#es Eac. record ty#e defines a fixed num)er of fie'ds or attri)utes-

??

Definition of 'DMS

Re'ationa' (ata)ase *anagement System 0R(1*S2 is a (ata)ase *anagement System 0(1*S2 t.at is )ased on t.e Re'ationa' mode'-

?2

Database (or)ali*ation

Ho& to reduce data redundancy and inconsistency in data)ase ta)'es; (ata redundancy and inconsistency in data)ase ta)'es can )e reduced )y fo''o&ing a #rocess ca''ed !orma'i,ation(ata)ase !orma'i,ation/ (ata)ase !orma'i,ation is t.e #rocess of organi,ing t.e fie'ds and ta)'es of a re'ationa' data)ase to minimi,e redundancy and de#endency !orma'i,ation usua''y in$o'$es di$iding 'arge ta)'es into sma''er 0and 'ess redundant2 ta)'es and defining re'ations.i#s )et&een t.em T.e o)6ecti$e is to iso'ate data so t.at additions+ de'etions+ and modifications of a fie'd can )e made in 6ust one ta)'e and #ro#agated t.roug. t.e rest of t.e data)ase $ia defined re'ations.i#s-

(or)al +or)s

Nor!al ,or!s: Edgar 4- Codd+ t.e in$entor of t.e Re'ationa' *ode'+ introduced t.e conce#t of !orma'i,ation in ?><@- Ae no& %no& t.is conce#t as t.e 4irst !orma' 4orm 0?!42 Codd &ent on to define t.e Second !orma' 4orm 02!42 and T.ird !orma' 4orm 0 !42 in ?><?+ and Codd and Raymond 4- 1oyce defined t.e 1oyce-Codd !orma' 4orm 01C!42 in ?><3 "nforma''y+ a re'ationa' data)ase ta)'e is often descri)ed as Bnorma'i,edB if it is in t.e T.ird !orma' 4orm- *ost !4 ta)'es are free of insertion+ u#date+ and de'etion anoma'ies-

?3

(or)al +or)s !ontd"#


To understand norma' forms+ consider t.e fo''o&ing denorma'i,ed data)ase ta)'e- !o& &e &i'' norma'i,e t.e data of t.e fo''o&ing ta)'e using norma' forms-

?8

+irst (or)al +or)

,irst Nor!al ,or! #-N,%: A data)ase ta)'e is said to )e in ?!4 if it contains no re#eated fie'dsCco'umns T.e #rocess of con$erting t.e U!4 ta)'e into ?!4 is as fo''o&s/ Se#arate t.e re#eated fie'ds into ne& data)ase ta)'es a'ong &it. t.e %ey from denorma'i,ed data)ase ta)'e T.e #rimary %ey of ne& data)ase ta)'es mig.t )e a com#osite %ey-

?:

+irst (or)al +or) !ontd"#

,irst Nor!al ,or! #-N,%

?<

Second (or)al +or)

(econd Nor!al ,or! #.N,%: A data)ase ta)'e is said to )e in 2!4 if it is in ?!4 and contains on'y t.ose fie'dsCco'umns t.at are functiona''y de#endent 0t.e $a'ue of t.e fie'd is determined )y t.e $a'ue of anot.er fie'd0s22 on t.e #rimary %ey "n 2!4+ &e remo$e t.e #artia' de#endencies of any non-%ey fie'd T.e #rocess of con$erting t.e data)ase ta)'e into 2!4 is as fo''o&s/ Remo$e t.e #artia' de#endencies 0a ty#e of functiona' de#endency &.ere a fie'd is on'y functiona''y de#endent on t.e #art of #rimary %ey2 of any non-%ey fie'd "f fie'd 1 de#ends on fie'd A and $ice $ersa+ for a gi$en $a'ue of 1+ &e .a$e on'y one #ossi)'e $a'ue of A and $ice $ersa+ t.en &e #ut t.e fie'd 1 into ne& data)ase ta)'e- "n t.e ne& ta)'e+ 1 &i'' )e #rimary %ey and a'so mar%ed as foreign %ey in #arent ta)'e-

?=

Second (or)al +or) !ontd"#


(econd Nor!al ,or! #.N,%: 2!4 of t.e ?!4 ta)'es s.o&n a)o$e are as fo''o&s/

?>

Third (or)al +or)

/hird Nor!al ,or! #0N,%: A data)ase ta)'e is said to )e in !4 if it is in 2!4 and a'' non %ey fie'ds are de#endent on a #rimary %ey- Ae can a'so consider a ta)'e to )e in !4 if it is in 2!4 and none of t.e fie'ds of t.e ta)'e are transiti$e'y functiona''y de#endent on t.e #rimary %ey T.e #rocess of con$erting a ta)'e into !4 is as fo''o&s/ Remo$e t.e transiti$e de#endencies 0a ty#e of functiona' de#endency &.ere a fie'd is functiona''y de#endent on t.e fie'd t.at is not t.e #rimary %eyHence its $a'ue is determined+ indirect'y )y t.e #rimary %ey2 *a%e se#arate ta)'e for transiti$e de#endent fie'd-

2@

Third (or)al +or) !ontd"#


/hird Nor!al ,or! #0N,%:

2?

Boyce !odd (or)al +or)

$oyce 1odd Nor!al ,or! #$1N,%: A data)ase ta)'e is said to )e in 1C!4 if it is in !4 and contains eac. and e$ery determinant as a candidate %ey T.e #rocess of con$erting a ta)'e into 1C!4 is as fo''o&s/ Remo$e t.e non-tri$ia' functiona' de#endency

*a%e se#arate ta)'e for t.e determinants

Let7s consider t.e s#ecia' situation gi$en )e'o& to understand 1C!4/

22

Boyce !odd (or)al +or) !ontd"#

$oyce 1odd Nor!al ,or! #$1N,% : After a##'ying 1C!4/

S,%

Question : How the data is access fro! R"$&(?


AN(: T.roug. SQL-

23

S,%
Structured Query Language 0SQL2 "t is a s#ecia'-#ur#ose #rogramming 'anguage designed for managing data in R(1*S "t is a 3t. Deneration Language or 3DLWhat is -2L3 .2L3 02L3 42L3 52L?

28

-(SI S,%
Question/ (oes #ro6ects recommend %no&'edge of A!S" SQL; Ans&er/ Yes A!erican National (tandards 6nstitute #AN(6%: "t is a #ri$ate non-#rofit organi,ation t.at is res#onsi)'e for de$e'o#ment of $o'untary standards for #roducts+ ser$ices+ #rocesses+ systems+ and #ersonne' in t.e United States SQL &as ado#ted as a standard )y t.e American !ationa' Standards "nstitute 0A!S"2 in ?>=: as SQL-=: and t.e "nternationa' 5rgani,ation for Standardi,ation 0"S52 in ?>=<Question / (o you &ant more c'arification on &.y one s.ou'd fo''o& A!S"; Ans&er/ Let us understand &.y one s.ou'd ad.ere to A!S""n t.is course+ &e &i'' ad.ere to A!S" SQL syntax-

23

Why -(SI S,%?

A.y do &e need A!S" SQL standard; Ait.out a centra' standard entity+ e$ery data)ase manufacturer &ou'd )e free to use &.ate$er syntax t.ey find a##ro#riate E$en t.oug. t.ere are some $ariations from one to t.e next regarding $arious extensions+ t.e main code is going to )e t.e same from one to anot.er A SELECT &i'' a'&ays )e a SELECT instead of a SELECT on one+ DET on anot.er+ REA( on a t.ird+ etc T.is &i'' not a''o& $endor )ased mono#o'y-

!ote/ E$ery $endor a$ai'a)'e in mar%et .as t.eir o&n "6ALE1/( 0somet.ing additiona' a#art from A!S" recommendation2 ET.e dia'ect of t.e data)ase is sim#'y a term t.at define t.e s#ecific features of t.e SQL 'anguage t.at are a$ai'a)'e &.en accessing t.at data)ase-F
2:

,uestions

2<

.eywords

2=

!hec/ 0our Understandin&

2>

Su))ary

"n t.is session you .a$e 'earned t.e fo''o&ing/ (ata)ase 0(12 is a co''ection of 'ogica''y re'ated data (ata)ase *anagement System 0(1*S2 is a set of soft&are or #rograms t.at ena)'es storing+ modifying+ and extracting information from a data)ase (ata *ode' is a re#resentation of a rea' &or'd situation a)out &.ic. data is to )e co''ected and stored in a data)ase Re'ationa' (ata)ase *anagement System 0R(1*S2 is a (ata)ase *anagement System 0(1*S2 t.at is )ased on t.e Re'ationa' mode'-

Su))ary !ontd"#

(ata)ase !orma'i,ation is t.e #rocess of organi,ing t.e fie'ds and ta)'es of a re'ationa' data)ase to minimi,e redundancy and de#endencyStructured Query Language 0SQL2 is a s#ecia'-#ur#ose #rogramming 'anguage designed for managing data in Re'ationa' (ata)ase *anagement Systems 0R(1*S2SQL &as ado#ted as a standard )y t.e American !ationa' Standards "nstitute 0A!S"2 in ?>=: as SQL-=: and t.e "nternationa' 5rgani,ation for Standardi,ation 0"S52 in ?>=<-

Source
.tt#/CCen-&i%i#edia-orgC&i%iCSQL

A draft of A!S" SQL/2@@= &.ic. is free'y do&n'oada)'e as ,i# G?2-?*1H arc.i$e HERE-

(isc'aimer/ Parts of t.e content of t.is course is )ased on t.e materia's a$ai'a)'e from t.e &e)sites and )oo%s 'isted a)o$e- T.e materia's t.at can )e accessed from t.e 'in%ed sites are not maintained )y Cogni,ant Academy and &e are not res#onsi)'e for t.e contents t.ereof- A'' trademar%s+ ser$ice mar%s+ and trade names in t.is course are t.e mar%s of t.e res#ecti$e o&ner0s2-

ANSI SQL
You have successfully completed the session on

Understanding SQL

!han&e %o&
Version Nu! er
V-78

1han'es !ade
6nitial Version (lide No7 1han'ed $y Effective "ate 1han'es Effected

V-7-

You might also like