📄 Page
1
Sql for beginners A comprehensive tutorial on mastering sql programming and database management systems, presented in sequential steps. Vera poe
📄 Page
2
© copyright 2024 by vera poe all rights reserved. The content contained within this book may not be reproduced, duplicated or transmitted without direct written permission from the author or the publisher. Under no circumstances will any blame or legal responsibility be held against the publisher, or author, for any damages, reparation, or monetary loss due to the information contained within this book, either directly or indirectly. Legal notice: This book is copyright protected. It is only for personal use. You cannot amend, distribute, sell, use, quote or paraphrase any part, or the content within this book, without the consent of the author or publisher. Disclaimer notice: Please note the information contained within this document is for educational and entertainment purposes only. All effort has been executed to present accurate, up to date, reliable, complete information. No warranties of any kind are declared or implied. Readers acknowledge that the author is not engaging in the rendering of legal, financial, medical or professional advice. The content within this book has been derived from various sources. Please consult a licensed professional before attempting any techniques outlined in this book. By reading this document, the reader agrees that under no circumstances is the author responsible for any losses, direct or indirect, that are incurred as a result of the use of information contained within this document, including, but not limited to, errors, omissions, or inaccuracies.
📄 Page
3
Table of contents Introduction Chapter 1: understanding databases Chapter 2: sql basics What’s sql? Data types Chapter 3: your first database Creating the database with a rad Creating the database with sql Chapter 4: exploring data with select Select syntax Chapter 5: math and statistics with sql Mathematical operators Chapter 6: relational operators Union Intersect Except Join operators Chapter 7: handling time Understanding time Chapter 8: query techniques Subqueries Table expressions Cross tabulations Chapter 9: database security
📄 Page
4
Access levels Revoking privileges Conclusion
📄 Page
5
INTRODUCTIOND E Structuredd equeryd elanguage,d ealsod eknownd easd esql,d eisd ead especiald eprogrammingd elanguaged ethatd eisd eusedd etod eanalyzed edatabasesd ethatd eared emaded eofd emultipled edatad erichd etables.d ethed erootsd eofd ethisd elanguaged ecand ebed etracedd ebackd etod ethed e70s,d ehoweverd ethatd edoesn’td emeand eitd ebecamed eobsolete.d eond ethed econtrary,d esqld eisd emored epopulard ethand eeverd ebefore.d e Hered eared esomed eofd ethed efieldsd ewhered esqld eisd eusedd etoday:d e Datad emining:d esqld egivesd eyoud ethed eabilityd etod eanalyzed especificd edatad eduringd ecertaind eperiodsd eofd etime,d easd ewelld easd emonitord etablesd eandd eupdates.d e Databased emanagement:d esqld eprogrammingd eskillsd eared ead emustd ehaved ewheneverd ead edatabased eisd einvolved.d ewhetherd eyoud eared eworkingd eford ethed egovernment,d ead esmalld ebusiness,d eord ead elarged eenterprise,d eyoud ewilld eencounterd edatabases.d esqld eoffersd eyoud eeveryd etoold eyoud eneedd eandd eisd etoday’sd estandardd eind eworkingd ewithd edata.d e Sqld eprogramming:d eyoud emightd enotd ewantd etod emanaged edatabasesd eord emined edata,d eandd eyoud edon’td ehaved eto.d eknowingd ehowd etod eprogramd eind esqld ealoned eisd eand eimportantd eskilld ethatd eisd eind ehighd edemandd eond ethed ecurrentd ejobd emarket.d esqld eisd efrequentlyd ecombinedd ewithd eotherd elanguagesd esuchd easd ec++d eandd epythond eind eorderd etod ecreated epowerfuld eapplications.d e Thisd eisd ewhered esqld eford ebeginners:d ead estepd ebyd estepd eguided etod elearnd esqld eprogrammingd eandd edatabased emanagementd esystemsd ecomesd ein.d ethed epurposed eofd ethisd ebookd eisd etod ehelpd eyoud eunderstandd ethed epowerd eofd edatad eandd ehowd etod eworkd ewithd edatabases.d ethisd eguided ewilld etaked eyourd ehandd eandd eteachd eyoud estepd ebyd estepd ehowd etod ecreated edatabases,d etables,d eandd eanalyzed edata.d e
📄 Page
6
Thisd ebookd eisd edividedd eintod esmall,d ebited esized echunksd ethatd ewilld eshowd eyoud ehowd etod egetd estartedd ewithd esqld eandd edatabases.d eyoud ewilld elearnd ead egreatd edeald eofd etheory,d ebutd eyoud ewilld ealsod eworkd ethroughd ead enumberd eofd epracticald eexercisesd eandd eexamplesd ethatd ewilld eallowd eyoud etod ebuildd ead eproperd efoundation.d ehowever,d ekeepd eind emindd ethatd eyoud ewilld ehaved etod epracticed eond eyourd eownd eandd eexpandd eyourd eknowledged efurtherd ebyd ecreatingd eyourd eownd edatabases.d esqld eisd efived edecadesd eoldd eandd ehered etod estay,d esod estartd elearning!
📄 Page
7
CHAPTERD E1:D EUNDERSTANDINGD EDATABASESD E Computersd ehaved ewithoutd ead edoubtd erevolutionizedd eeveryd etaskd ewed eperform.d ewed enod elongerd erelyd eond etypewritersd etod erecordd etextd edocuments,d eord emechanicald ecalculatorsd etod eperformd earithmeticd ecalculationsd eford eus.d efurthermore,d ewed enod elongerd ehaved etod erelyd eond eentired eroomsd eandd ebasementsd efilledd ewithd ecabinetsd epackedd etod ethed ebrimd ewithd efoldersd eandd efiles.d estoringd einformationd eisd enod elongerd ead equestiond eofd ephysicald espace.d ecomputersd eared ecapabled eofd ead elotd emored ewhend ecomparedd etod ethed eoldd etechniquesd eandd etools,d etheyd eared efaster,d eandd etheyd ebarelyd erequired eanyd espace.d ehowever,d ethered eared edownsidesd ethatd ewed eneedd etod etaked eind econsiderationd easd ewell.d eford einstance,d ewed enod elongerd ephysicallyd eaccessd ealld ethed einformationd ewed estore.d ewhend ead ehardd edrived efailsd eord ead ecomputerd ecrashes,d ead especializedd etechniciand eisd ethed eonlyd ehoped eandd erecoveringd elostd edatad ecand etaked etime.d eevend ethen,d ethere’sd enod eguaranteed ethatd ealld eofd ethed edatad eisd eintact.d eond ethed eotherd ehand,d epapersd edidn’td egived eyoud eerrors.d ethed eworstd escenariod einvolvedd espillingd ecoffeed eond ead ecopyd eord edroppingd eitd eandd epickingd eitd eup.d e Modernd edatad estoraged erequiresd ead enumberd eofd eprecautionsd eind eorderd etod ekeepd ethed edatad esafed efromd ecomputer,d easd ewelld easd ehuman,d efailures.d ehered eared ethed emaind efactorsd eyoud eneedd etod etaked eintod econsiderationd ewhend estoringd einformation:d e Thed eprocessd eofd estoringd edatad eneedsd etod ebed efastd ebecaused eitd eneedsd etod ebed eperformedd eoften.d e
📄 Page
8
Reliabled estoraged eisd ecrucial.d eyoud eneedd etod emaked esured ethed edatad ewilld estilld ebed ethered eafterd eyearsd eofd estorage.d elosingd eitd eind ethed efard ereachesd eofd ecyberspaced ebecaused eofd eand eunreliabled eserviced eord efaultyd ehardwared ecand ecaused eexpensived edamages.d e Retrievingd edatad eneedsd etod ebed efastd eandd easd epainlessd easd epossible,d enod ematterd ehowd evastd ethed eamountd eofd einformationd eis.d e Thed eabilityd etod efindd eandd eextractd eonlyd ethed einformationd eyoud eneedd efromd ethed estoraged esystemd eisd eimportant.d ewhend eyoud ehandled eterabytesd eworthd eofd edatad eyoud eneedd ead ereliabled emethodd eofd efilteringd eit.d e Thisd eisd ewhatd edatabasesd eared efor.d ethed ebasicd eprincipled eofd estoringd einformationd eisd ethatd eifd eyoud eneedd etod emanaged emored ethand etwelved eitemsd eofd edata,d eyoud eshouldd ebed eusingd ead edatabase.d ethisd eisd ewhered esqld ecomesd ein.d epronouncedd ebyd ereadingd ethed eindividuald elettersd eord easd ethed ewordd e“sequel”d e(there’sd estilld ead edebated eond ethisd eamongd esqld especialists),d esqld eallowsd eyoud etod ecreated ead edatabased ewhered eyoud ecand estored ead enumberd eofd eitemsd eandd emanaged ethem.d eitd ewasd ecreatedd eind ethed e70sd ebyd eibm,d ebutd eevend etodayd esqld eremainsd ead estandardd eind ethed eindustry.d ethered eared eseverald edatabased etypesd ewhichd ehandled edatad emanagementd eind edifferentd eways,d ehoweverd ewed eared egoingd etod edeald ewithd ethed eobject-relationald edatabases.d eind ethed eearlyd eyearsd eofd esql’sd edevelopmentd eitsd efocusd ewasd eond erelationald edatabases,d ehoweverd enowadaysd eitd ereliesd eond ead ehybridd emodel.d e Ind ethisd echapterd ewed eared egoingd etod etaked ead elookd eatd ealld eofd ethesed enotionsd eind eorderd etod egived eyoud ead ebasicd eunderstandingd eofd esql.d ebefored ewed edived eintod ethed etechnicalities,d ehowever,d eyoud eshouldd elearnd eaboutd edatabasesd eind egeneral,d eincludingd ethed emajord emodelsd esuchd easd ethed erelationald emodel,d eandd etheird emaind efeatures.d e
📄 Page
9
Databasesd e Thed emeaningd ebehindd ethed ewordd e“database”d ehasd echangedd esod emuchd eind ethed epastd ecoupled eofd edecadesd ethatd eitd ebarelyd epreservesd eitsd eownd edefinition.d etod esomed epeople,d ead edatabased erefersd etod eanyd enumberd eofd edatad eitemsd econtainedd eind ead ebookd eord elist.d etod eothers,d eitd erefersd etod ead erepositoryd eofd estructuredd edata,d eord erecords,d ewhichd ecand ebed eaccessedd ethroughd ead ecomputerd esystem.d ewed ewilld efocusd eond ethed esecondd edefinition,d ewhichd ealsod eincludesd esql.d ekeepd eind emindd ethatd eind ethisd ecased ead erecordd erefersd etod ethed erepresentationd eofd eand eitem.d eford einstance,d eyoud eared erunningd eyourd eownd ebusinessd eandd etherefored eyoud ewilld ecreated eoned erecordd eford eeveryd euniqued eclient.d ethesed erecordsd ewilld econtaind ead enumberd eofd echaracteristicsd ethatd edescribed ethed eobject.d eford eexample,d eyoud ecand eincluded edatad esuchd easd enames,d ephoned enumbers,d eaddressd eandd esod eon.d e Ad edatabase,d ehowever,d edoesn’td econtaind eonlyd edata.d eitd ealsod eincludesd emetadata,d ewhichd ehasd ethed epurposed eofd edefiningd ethed einformation’sd estructured einsided ethed edatabase.d ewhyd eisd ethisd eimportant?D ebecaused eifd eyoud eknowd ehowd ethed edatad eisd eorganizedd ethend eyoud ecand eaccessd eit,d emanaged eit,d emaintaind eit,d eandd emodifyd eit.d ealld eofd ethisd emeansd ethatd ead edatabased eisd eself-describing,d easd eitd econtainsd einformationd eond ethed econnectionsd ebetweend ethed edatad eobjects.d ethed emetadatad eisd ereservedd einsided ewhat’sd eknownd easd ead edatad edictionary.d ethed edictionaryd eisd ewhatd edescribesd ethed ecomponentsd eofd ead edatabase,d enamelyd ethed etable,d ethed erows,d ecolumns,d eandd esod eon.d eond ead esided enote,d eyoud eshouldd eknowd ethatd eflatd efiled esystemsd edod enotd econtaind emetadata.d ethisd emeansd ethatd ethed eprogramsd ethatd ehandled ethesed efilesd eneedd etod ehaved esomed eformd eofd eand eequivalentd eintegrated.d ewed ewilld ediscussd eflatd efilesd eind emored edetaild esoon.d e Thed esized eofd ead edatabased evariesd easd ewell,d edependingd eond ethed enumberd eofd erecordsd eitd econtains.d eford einstance,d eyoud ecand ehaved eanywhered
📄 Page
10
ebetweend ead edozend edatad eobjectsd eandd emillions.d eford enow,d eyoud edon’td ehaved etod eworryd eaboutd eanyd esuchd elimitations.d ehowever,d edatabasesd ecand ebed ecategorizedd eind ethreed edifferentd eways:d e Personald edatabasesd eared ethed esmallest.d etheyd eared estoredd eond ethed euser’sd epersonald ecomputerd eandd eared echaracterizedd ebyd ead ebasicd edatad estructure.d e Groupd edatabases,d eond ethed eotherd ehand,d eared emored ecomplex.d etheyd eared eintendedd etod ebed eusedd ebyd ead edepartmentd eord eteam,d ewhichd emeansd ethatd etheyd econtaind ead egreatd edeald emored edatad ethand ead epersonald edatabase.d ethisd emeansd ethatd etheyd ealsod eneedd etod ebed eaccessedd efromd emultipled edevicesd eatd ethed esamed etime.d e Finally,d ewed ehaved ethed eenterprised eversiond eofd ead edatabase.d etheyd eared ehuge,d ecomplex,d eandd eneedd ethed emostd ereliabled eequipmentd eind eorderd etod ebed esafelyd estoredd eandd emaintained.d e Asd eyoud ecand esee,d eyoud ecand ecategorized ead edatabased ebyd elookingd eatd ethreed eattributes:d ehowd elarged eitd eis,d ehowd emanyd epeopled eneedd etod ehaved eaccessd etod eit,d eandd ewhatd ekindd eofd etechnicald eequipmentd eitd erequires.d e Databased emanagementd esystemsd e Ind eorderd etod emanaged ead edatabased eandd eanyd eapplicationsd ethatd ehaved eaccessd etod eit,d ewed eneedd etod eused ead edatabased emanagementd esystem.d ekeepd eind emindd ethatd ead edatabased eisd enothingd emored ethand ead estructured edesignedd etod econtaind einformation.d ewed eneedd ead etoold ethatd eactuallyd ecreatesd ethatd estructured eandd ethend eallowsd eusd etod eaccess,d emaintain,d eord emodifyd ethed edatad einsided eit.d ethered eared emanyd esuchd eprogramsd eavailabled eford efreed eord eatd ead ecertaind ecost.d e Notd ealld edatad emanagementd esystemsd eared ecreatedd eequally,d ehowever.d ethed eoned eyoud eneedd edependsd eond eyourd egoald eandd eond eyourd erequirements.d eford einstance,d esomed eofd ethesed eprogramsd eared edesignedd etod eoperated eond
📄 Page
11
eprofessional,d eenterprise-grade,d eequipmentd eandd ehandled emassived edatabases.d eond ethed eotherd ehand,d esomed eofd ethemd eared eintendedd etod eworkd eond ebasic,d epersonald eused elaptops.d ehowever,d ekeepd eind emindd ethatd ethesed etoolsd esometimesd eneedd etod efunctiond eatd ethed esamed etimed eond edifferentd ehardwared esettingsd erunningd edifferentd eoperatingd esystems.d efurthermore,d ewed ealsod ehaved ethed ecloudd etod econsiderd easd ead estoraged eoption.d enowadays,d eyoud ecand egaind epublicd eonlined estoraged ethroughd eservicesd eofferedd ebyd eorganizationsd esuchd easd eamazond eandd emicrosoft.d e Thed ecloudd eisd eoned eofd ethosed etermsd eyoud ewilld eheard eoftend eind eanyd etechd efieldd edued etod ethed emassived eincreased eind ecomputerd eprocessingd epowerd eandd estoraged ecapabilitiesd ethatd emanyd ebusinessesd erequired etoday.d ewhatd eyoud eshouldd eknowd eford enowd eind ecased eyoud edon’t,d eisd ethatd ethed ecloudd eisd eand eassemblyd eofd ecomputersd ethatd emaked etheird eresourcesd eavailabled etod eanyoned eviad ethed einternet.d ethisd emeansd ethatd eanyoned ecand eaccessd ethesed eservicesd efromd ethed ecomfortd eofd etheird ehomed einsteadd eofd ephysicallyd econnectingd etod ead edatad ecenter.d eind ethisd ecased ead edatad emanagementd esystemd ewithd ecloudd ecapabilitiesd ecand eprovided eyoud ewithd ethed efunctionalityd eyoud eneedd etod emanaged eyourd edatabasesd eremotely.d e Databased emanagementd esystemsd eensured ethed eflowd eofd edatad ebetweend ethed euser,d eandd ethed esystemd eisd ealwaysd ethed esamed enod ematterd ethed etyped eofd esystemd eandd ethed esized eofd ethed edatabase.d e Flatd efilesd e Ad eflatd efiled eisd ethed emostd ebasicd etyped eofd efiled eyoud ecand eworkd ewith.d eitd eisd eappropriatelyd enamedd ebecaused eitsd edatad estructured eisd eminimalisticd eandd eitd eonlyd econtainsd ead elistd eofd erecords.d ekeepd eind emindd ethatd eitd edoesn’td econtaind eanyd emetadata.d ewithd ethatd eind emind,d ehere’sd eand eexampled eofd einformationd ekeptd ewithd ethisd etyped eofd efile:d e Johnd ewatsond e3453d es.d ecabind elaned erdd eanaheimd e
📄 Page
12
Miked emoriarty6748d es.d erosed elaned esantad eanad e Philipd ebaggins234d ewordswothd eavenueaberdeend e Samueld esmith2456d esmithd estreetd ebirminghamd e Georged etook543d enewtond eclosed ecanterburyd e
📄 Page
13
Robertd efullerd e8943d eoldd elaned echelmsfordd e Juliusd estyles343d etrinityd eroadd edurhamd e Anned ecromwell85d ehighd elaneinvernessd e Asd eyoud ecand esee,d eflatd efilesd econtaind erawd edata.d ehowever,d ethed efiled eisd estructuredd ebyd elimitingd eeachd efieldd etod ead ecertaind enumberd eofd echaracters.d ethed eassignedd echaracteristicsd eared esetd eind estoned ebyd ethed ecreator.d ethisd emeansd ethatd ewhateverd eprogramd eyoud eused etod ereadd eandd eprocessd eflatd efilesd eneedsd etod ebed eabled etod edetectd eeachd efieldd eseparatelyd eandd eidentifyd ethed einformation.d ekeepd eind emindd ethatd eind ethisd ecased ewed eared enotd edealingd ewithd ead edatabased eperd ese.d ewed edon’td ehaved ethed etypicald estructured ewhichd edefinesd ethed eseparationd ebetweend ethed efields.d ethisd emeansd ethatd ethed einformationd eisd ereadd edirectlyd eandd etherefored eflatd efilesd ecand ebed eprocessedd eextremelyd efast.d ehowever,d ethered eisd ead edownside.d e Ind eorderd etod emanipulated ethed einformationd efromd ead eflatd efiled eyoud eneedd etod eused especializedd etoolsd ethatd edetectd ewhered ecertaind edatad eisd estored.d ethisd emeansd ethatd eyoud eshouldd eoptd eford eflatd efilesd eonlyd ewhend ecreatingd esmallerd elistsd eofd edatad eitems.d ethed emored ecomplexd eyourd esystemd eis,d ethed emored edifficultd eitd ebecomesd etod ereadd ethed efiled eandd emanipulated eitsd edata.d edatabasesd emayd etaked esomewhatd elongerd etod eprocess,d ebutd eunliked eflatd efiled esystems,d etheyd eared emored eversatiled ebecaused eyoud ecand eincreased etheird esized easd eneeded.d eadditionally,d ethed eprogramsd ethatd eworkd ewithd edatabasesd eared efard emored eversatiled eandd ewilld eworkd enod ematterd ethed eoperatingd esystemd eyou’red eusing.d e Whiled eflatd efilesd ehaved etheird euse,d edatabasesd eared eeasierd etod ehandled ewhend edevelopingd ead eprogram.d ead esoftwared edeveloperd ewon’td eneedd etod eknowd ealld ethed edetailsd eaboutd ehowd ethed efiled estoresd ethed edata.d ethatd eisd ewhatd ead edatabased emanagementd esystemd eisd efor.d eitd ewilld edeald ewithd ealld ethed edatad emanipulation,d ewhiled ethed etoolsd eyoud eused eond eflatd efilesd eneedd etod eincluded
📄 Page
14
ethed esamed efunctionsd eind eitsd eownd ecode.d eind eotherd ewords,d ewhend eworkingd ewithd eflatd efilesd eyoud ewilld eneedd etod eincluded etheird edatad emanipulationd ecoded eind ealld ethed edifferentd etoolsd eyou’red eusing.d ethisd eisd enotd ethed ecased ewhend eitd ecomesd etod edatabasesd ebecaused ethed edatabased emanagementd esystemd edoesd ealld eofd ethisd eford eyou.d eanyd eotherd etoolsd eyoud eneedd etod eused ecand eworkd ewithd ethed edatad ewithoutd eincludingd ethed esamed edatad emanipulationd ecode.d efurthermore,d esomed eprogramsd ethatd eincluded ethed edatad emanipulationd efeaturesd eford eflatd efilesd ewilld eonlyd erund eond ead eparticulard esystem,d ewhichd emeansd ethatd ethed euserd ewouldd ehaved etod emigrated ethed eprogramd etod ead edifferentd esystemd ethatd eisd ecurrentlyd eind euse.d ethisd eisd etimed econsuming.d ethered eared edifferencesd eind ecoded ewhend eitd ecomesd etod edifferentd eoperatingd esystems.d e Databased etypesd e Thed everyd efirstd edatabased emodelsd ewered ebuiltd eusingd ead ehierarchy-basedd estructure.d ethisd eleadd etod ead enumberd eofd eproblems,d eincludingd ethed efactd ethatd esuchd edatabasesd ewered enotd eeasyd etod emodifyd eandd emaintaind edued etod etheird einflexibility.d ethed estructurald eissued eandd evariousd eredundancyd eproblemsd ehaved eledd etod ethed edevelopmentd eofd ead enetworkd etyped edatabase.d eitsd epurposed ewasd etod eeliminated esuchd eimperfections.d etheyd eindeedd eofferedd ethed eadvantaged eofd ead eneard elackd eind eredundancy,d ehoweverd etod eachieved ethisd equalityd eanotherd esacrificed ehadd etod ebed emade.d ethed estructured eofd ead enetworkd emodeld edatabased ewasd ehighlyd ecomplex,d eandd etherefored eledd etod eanotherd esetd eofd eproblems.d e And eanswerd etod ethesed etechnicald eissuesd ewasd esoond eofferedd ewithd ethed edevelopmentd eofd ethed erelationald edatabase.d ethed estructured ewasd esimpled eandd eminimald eredundancyd ewasd eoned eofd eitsd emaind efeatures.d ewithd ethed ecreationd eofd ethisd enewd edatabased etyped esqld eenteredd ethed estage.d eitsd
📄 Page
15
epurposed ewasd etod eturnd ethed erelationald edatabasesd eintod esomethingd erevolutionaryd eandd esendd ethed eotherd emodelsd eintod eobscurity.d e Thed erelationald edatabased e Thed efirstd erelationald emodeld ewasd edevelopedd eind ethed e70sd ebyd eedgard efrankd ecoddd efromd eibm,d ehoweverd eitd estartedd eseeingd ethed elightd eofd edayd ecommerciallyd eonlyd etend eyearsd elater.d ewithd ead enewd etyped eofd edatabase,d ead enewd edatabased emanagementd esystemd ewasd eneeded.d ethisd eisd ehowd eoracled ecamed etod ebe:d ead enewd eanswerd egivend ebyd ead esmalld estartupd ecompany.d eatd ethisd epoint,d erelationald edatabasesd eenteredd ethed emainstream.d ethisd emaded epossibled ethed eabilityd etod emodifyd ethed estructured eofd ethisd emodeld ewithoutd echangingd ethed edesignd eofd ethed eprogramsd eusedd eond ethed eotherd edatabased etypes.d eford einstance,d eind eorderd etod ecreated emored ecolumnsd einsided ethed edatabased etabled ealld eyoud eneededd etod edod ewasd eaddd ethemd etod eitd ewithoutd eanyd eotherd etimed econsumingd emodifications.d ethed eapplicationsd ethatd ereliedd eond ethed edatabased edidd enotd erequired eanyd echanges.d e Anotherd epowerfuld eadvantaged ewasd ethed efactd ethed esomed edatad ecouldd ebed estoredd eind eoned etabled ewhiled eotherd edatad ecouldd ebed eind ead edifferentd etable.d eneitherd eofd ethesed etablesd ehadd etod ebed econnectedd etod eeachd eotherd eind eanyd eway.d etherefore,d eyoud ecouldd echanged ethed einformationd eind eoned eofd ethemd ewithoutd ehavingd ead enegatived eeffectd eond ethed eother.d e Nowd ethatd eyoud eknowd ethed ebackgroundd eofd ethed erelationald emodel,d elet’sd eexplored ethed ecomponentsd eofd ead erelationald edatabased eandd eseed ewhatd eit’sd emaded eof.d efirst,d eimagined eyourd efriendsd eandd efamilyd egatheringd eatd eyourd etable.d ethesed eared eyourd epersonald erelationsd eandd edatabasesd ehaved ethemd easd ewell,d ehoweverd eeachd eelementd ehasd ead etabled eofd eitsd eown.d eind eotherd ewordsd ead erelationald edatabased eisd econstructedd eusingd ead enumberd eofd erelationsd e(atd eleastd eone).d eyoud ecand eanalyzed ethesed edatabased erelationsd easd eand earrayd ewhichd econtainsd eonlyd ecolumnsd eandd erows.d ethisd etwod
📄 Page
16
edimensionald earrayd ewouldd econtaind eonlyd euniqued erowsd efilledd ewithd eoned evalued eperd ecell.d e Ifd eyoud ehaved eissuesd eunderstandingd ethisd easpect,d ethinkd eofd eand eexceld espreadsheetd econtainingd ethed estatisticsd eofd eyourd efavorited eathletes.d eyoud ewilld ehaved ead enumberd eofd ecolumnsd ethatd erepresentd ead eplayer’sd estats,d esuchd easd enumberd eofd eseasonsd eplayed,d enumberd eofd egames,d escores,d emisses,d eandd esod eon.d ethesed ecolumnsd eared euniqued eford ealld erowsd eandd ewilld eneverd echanged etheird emeaning.d ethed erowsd econtaind ethed evaluesd eford eeachd eoned eofd ethesed estatistics.d ethisd espreadsheetd edatad ecand ealsod ebed einsertedd eintod ead erelationald edatabase.d etaked enoted ethatd ethed eorderd eind ewhichd eyoud eintroduced ethed edatad eitemsd edoesn’td ematter.d ethere’sd enod eneedd etod efollowd eand ealphabeticald eorderd eord eanythingd esimilar.d ewhend eyoud eused ead edatabased emanagementd esystemd etod ehandled ethed einformationd eitd ewilld eprocessd eeverythingd eatd eonced ewithoutd esearchingd eford esomed ekindd eofd ehierarchy.d e
📄 Page
17
Anotherd easpectd ethatd ealld edatabasesd eshared eisd esomethingd eoftend ereferredd etod easd ead e“view”.d eitd emightd enotd einvolved ead ebeautifuld elandscape,d ehoweverd eitd edoesd eprovided eyoud ewithd ethed evisuald esatisfactiond eofd eseeingd ethed emanyd ecolumnsd eandd erowsd eofd edatad eyoud ecreate.d ekeepd eind emindd ethatd edatabased etablesd edon’td enecessarilyd einvolved ealld eofd ethed edatad etheyd econtain.d eyoud ecand elimitd ethemd etod eonlyd ethed ecolumnsd eandd erowsd eyoud eared einterestedd eind eord ethed eonesd ethatd efitd ecertaind erequirementsd eford ead eproject.d eind eorderd etod eputd easided ethed einformationd eyoud edon’td ewant,d eyoud eneedd etod ebuildd ead eview.d eind eessence,d ethisd eisd ead eversiond eofd eyourd edatabased ewhichd ecand ebed eprocessedd eandd emanipulatedd ebyd ead enumberd eofd eprograms.d ealsod eknownd easd evirtuald etables,d ethed eviewsd ecand ebed econstructedd eusingd eeitherd ecertaind edatad efromd eoned etable,d eord efromd eseverald etablesd ethatd earen’td econnectedd etod eeachd eother.d ethisd emeansd ethatd eviewsd eared eind efactd enod edifferentd ethand eanyd etable.d eprogramsd eandd eusersd eseed ethemd ethed esamed eway.d ehowever,d ethered eisd eoned echaracteristicd ethatd esetsd ethemd eapart.d ethed etablesd eared epartd eofd ethed einformationd eitself;d etheyd eared eindependentd estructures.d ethed eviews,d eond ethed eotherd ehand,d eprovided eyoud ewithd ethed eabilityd etod eexamined ethed edatad evisually,d ebutd etheyd eared enotd epartd eofd eit.d e Let’sd etaked ead elookd eatd eand eexampled etod egaind ead ebetterd eunderstandingd eaboutd eviews.d ewed ehaved eoned edatabased ethatd econtainsd etwod edifferentd etables,d eoned ecalledd e“client”d eandd eanotherd eoned ecalledd e“invoice”.d ethed efirstd etabled econtainsd ead enumberd eofd ecolumnsd ethatd eholdd edatad eaboutd ethed eclient,d esuchd easd eclientd eid,d ename,d eaddress,d ephoned enumberd eandd esod eon.d ethed esecondd etabled econtainsd einformationd esuchd easd ethed einvoiced enumber,d eclientd eid,d esale,d etyped eofd epaymentd eandd esod eon.d enowd elet’sd esayd eyourd esupervisord ecomesd eind etod efindd eoutd ead eclient’sd ename,d eaddress,d eandd enumber.d enothingd eelsed eisd eofd einterestd etod ehim.d eind ethisd ecase,d eyoud edon’td eshowd ehimd ethed etables.d ethatd ewouldd ebed ead ewasted eofd ehisd evaluabled etimed esearchingd ethroughd ead egreatd edeald eofd einformationd eind eorderd etod efindd
📄 Page
18
esomethingd esod especific.d ethisd eisd ewhatd eviewsd eared efor.d eyoud eused ethed e“client”d etabled etod ecreated ead eviewd ethatd eholdsd eonlyd ethed edatad ehe’sd einterestedd ein,d enamelyd ethed ecolumnsd ehed easkedd efor.d ealld eyoud eneedd etod edod eisd especifyd ethed eviewd etod elimitd ethed erowsd eandd ecolumnsd eitd epullsd eoutd eofd ethed edatabase.d e Asd eyoud ecand eseed eind ethisd eexample,d eviewsd eared eextremelyd eusefuld ebecaused eyoud ecand eseparated ethed edatad eyoud eneedd efromd epossiblyd emillionsd eofd edatad eitemsd eyoud edon’td eneed.d eyoud ecand ealsod eformatd ethisd einformationd esafely,d eknowingd ethatd ethed edatad eitselfd eisd enotd emodified.d easd ementionedd eearlier,d ethed eoperationsd eyoud eperformd eond ethed edatad einsided ead eviewd edoesd enotd eaffectd ethed edatabased eitself.d efurthermore,d eusingd ead eviewd einsteadd eofd ethed edatabased etablesd ecand ealsod eserved easd ead esecurityd emeasured ebecaused ethered emightd ebed esomed einformationd eyoud eared enotd eallowedd etod eshow.d e Withd ethatd eind emind,d elet’sd eexplored ethed ecomponentsd ethatd eformd esuchd ead edatabased ebecaused ethere’sd emored einvolvedd ethatd ejustd etables.d edatabased einformationd eisd emaintainedd ethroughd ead ewell-definedd estructured ecomposedd eofd ead eschema,d edomain,d eandd econstraints.d ethed eschemad ehandlesd ethed ewayd ethed edatabases’d etablesd eared earranged,d ethed edomaind etellsd eusd ewhichd evaluesd ecand ebed estoredd einsided eofd ead ecolumn,d eandd ethed econstraintsd eared eusedd etod elimitd evariousd eusersd efromd eintroducingd ethed ewrongd einformationd einsided ethed etable.d elet’sd eanalyzed ethisd estructured eind emored edetail:d e Schema:d ethisd eisd eessentiallyd ethed estructured eitself,d ealsod eknownd easd ethed econceptuald eviewd eord elogicald eview.d eitd eisd ealsod ethed ecomponentd eofd ethed edatabased ewhichd erepresentsd ethed emetadata.d easd eyoud ealreadyd eknow,d emetadatad eisd ewhatd eprovidesd eusd ewithd ethed einformationd eaboutd ethed edatabase.d eitd edescribesd ethed estructure,d ethed etables,d eandd eeverythingd ethatd eisd estoredd ewithind ethem.d etherefore,d eyoud ecand esayd ethatd emetadatad eisd eind efactd edatad eond eitsd eown.d e
📄 Page
19
Domain:d eeachd etabled ecolumnd ehasd eand eattributed ewhichd einvolvesd ead enumberd eofd evalues.d ethed ecollectiond eofd ethesed evaluesd erepresentsd ethed edomaind eofd ethatd eattribute.d eford einstance,d elet’sd esayd eyoud ehaved ead edatabased ethatd econtainsd ead enumberd eofd edifferentd ecard emodels.d ethed etablesd eford ethesed ecarsd ewilld eincluded ead ecolumnd ecalledd e“color”.d enowd elet’sd esayd ethere’sd ead enissand eqashqaid ewhichd ecomesd eind eseverald edifferentd ecolorsd esuchd easd emetallicd esilver,d eblack,d epearld ewhite,d eandd echerryd ered.d ealld eofd ethesed ecolorsd etogetherd erepresentd ethed ecolord eattribute’sd edomain.d e Constraints:d etheyd eared easd eimportantd easd ealld ethed eotherd ecomponents,d ehoweverd etheyd eared eoftend eunderappreciatedd eandd eignored,d eespeciallyd ebyd ethosed ewhod ejustd estartd eoutd eind ethed etechnicald eworldd eofd edatabases.d easd ethed enamed esuggests,d ead edatabase’sd econstraintsd edefined ewhichd evaluesd ecand ebelongd etod eand eattribute.d ethed eprimaryd efunctiond eofd ead econstraintd eisd etod elimitd evariousd eusersd efromd eintroducingd ethed ewrongd einformationd eind ethed etable.d ekeepd eind emindd ethatd ealld eofd ethesed evaluesd ethatd edod ebelongd etod ead ecertaind edomaind emustd ealsod ecomplyd ewithd ethed econstraintsd ewed esetd eford eeachd ecolumn.d eapplyingd econstraintsd etod ead ecolumnd eisd eliked eapplyingd erigidd erestrictions.d ethisd emeansd ethatd ethed edomaind eofd ead ecolumnd eisd eind efactd edeterminedd enotd eonlyd ebyd ethed evaluesd ethemselvesd ebutd ebyd ethed econstraintsd easd ewell.d eind eourd eexampled ewithd ethed ecard emodeld edatabased ewed ecand eintroduced ead econstraintd etod eforced ethed ecolumnd ewithd ethed ecolord evaluesd etod eacceptd enod emored ethand efourd evalues.d etherefore,d eifd eanotherd euserd etriesd etod eaddd emored ecolorsd etod ethed elist,d etheyd ewilld enotd ebed eaccepted.d esuchd edatad eentryd elimitationsd eared epracticald eind esuchd ecasesd ebecaused eyoud edon’td ewantd esomeoned etod eintroduced ecertaind evaluesd ethatd edon’td eexist.d eimagined eand eemployeed eaddingd emintd egreend etod eoned eofd ethed emodels,d ewhend ethed emanufacturerd edoesn’td eofferd ethatd ecolor.d ethisd einformationd ecand ebed epassedd efurtherd etod epotentiald ecustomersd ewhod ewilld eeventuallyd easd ead eresultd eendd eupd edisappointedd ewhend etheyd efindd eoutd ethatd etheird echosend ecolord eonlyd eexistsd edued etod ead efaultyd edatabased eentry.d e
📄 Page
20
Relationald edatabasesd ehaved ebeend ethed eheightd eofd edatad estoraged eford ead elongd etimed eandd etheird esuccessd ehasd ekeptd ethemd eind eused etod ethisd eday.d ewhiled etheyd emayd enod elongerd ebed ethed emainstreamd echoiced eford emostd eusersd eandd ecompanies,d eyoud emightd estilld estumbled eupond ethemd eonced eind ead ewhile.d ehowever,d etheyd edod enotd eofferd ethed esolutiond etod eeveryd eproblem.d ethered eared evariousd elimitsd etod ethisd emodel.d eind ethed epastd ecoupled eofd edecades,d eobject-orientedd eprogrammingd ethroughd elanguagesd eliked ec,d ejava,d eandd ec++d ehasd emaded eitd eobviousd ethatd emored ecand ebed eachieved.d ethesed eprogrammingd elanguagesd eared efard emored epowerfuld ethand ethed eonesd eatd ethed etimed ewhend erelationald edatabasesd ebecamed ethed enorm.d etheyd ecand esolved ecomplexd eproblems,d eandd etheyd eofferd eadvancedd efeaturesd esuchd easd einheritance,d eencapsulations,d eobjectd eidentity,d eandd emuchd emore.d ewed eared enotd egoingd etod eexpandd eond eobject-orientedd eprogrammingd ebecaused ethatd eisd enotd ethed epurposed eofd ethisd ebook,d ehoweverd eyoud eshouldd eunderstandd ethatd emanyd eofd ethesed emodernd efeaturesd ecannotd ebed eusedd ewithd ethed erelationald emodel.d ethisd emeansd enewd edatabased emanagementd esystemsd ehadd etod ebed ecreatedd eind eorderd etod etaked eadvantaged eofd ethed enewd etechniques.d e Thed eobjectd emodeld ewasd ecreatedd easd ead eresponsed etod ethed enewd epossibilities,d ehoweverd eitd eneverd ebecamed epopular.d ekeepd eind emindd ethatd eobject-orientedd eprogrammingd eisd ethed emostd epopulard etyped eofd eprogrammingd eind etoday’sd etechd eindustriesd eacrossd ethed eboard,d ehoweverd ethed eobjectd emodeld ebroughtd enewd eissuesd ethatd ekeptd eitd efromd egrowingd eond eitsd eown.d ethisd enewd edatabased etyped ewasd esoond eafterd ecombinedd ewithd ethed erelationald emodeld eind eorderd etod ecreated ethed eobject-relationald emodel.d e Thed eobject-relationald edatabased e Bothd ethed erelationd emodeld eandd ethed eobjectd emodeld eofferedd eand earrayd eofd eadvantages.d efortunately,d ethed edevelopersd eatd ethed etimed ethoughtd eaboutd ethed epossibilityd eofd eprofitingd efromd ethed epowerd eofd eobject-orientedd edatabases,d easd ewelld easd ethed ecompatibilityd eofferedd ebyd ethed erelationald