Professional Documents
Culture Documents
relationaldatabase,this isnt alwaysthe case-at least not completely.In Chapter 1,I discussed
the basicsand foundations of relationaltheory but no discussionon this subjectwould biecom-
plete without looking at the rules that wereformulated in 1985in a two-prut article publishedby
Conxputerworldmagazine("IsYourDBMSReallyRelational?"and "DoesYburDBMSRun lBythe
Rules?"by E. E Codd,Computerworld,October14 and October21, 1985).JManywebsiteseilsoout-
line theserules.Theserules go beyond relationaltheory and definesmore speciflccriteria.that need
to be met in an RDBMS,if it's to be trulyrelational.
It might seemlike old news,but the samecriteria can still be usedtoday to measurehow rela-
tional a databaseis. Theserules arefrequentlybrought up in conversatior':rs when discussinghow
well a particular databasesewer is implemented.I presentthe rulesin this appendix,alorrgwith
brief commentsasto whether SQLServer2008meetseachof them, or ottrerwise.Relationaltheory
has come a long way sincetheseruleswereflrst published,and "serious"theoristshaveenhanced
and refinedrelationaltheory tremendouslysincethen, asyou'd expect.A good placefor more seri-
ousIearningis the websitehttp: //www.dbdebunk. com,run by C.I. Dateand FabianPascal,or any of
their books.If you want to seethe debateson theory the newsgroupcomp,, databases.theory is a
truly interestingplace.Of course,asthe coverof this book states,my goal is practicality,with a
foundation on theory so I won't delvetoo deeplyinto theory hereat all. I presentthese 12rules
simply to set a basisfor what a relationaldatabasestartedout to be and largelywhat it is amdwhat
it should be eventoday.
All theserules are basedupon what'ssometimesreferredto as thefoundation princi1tle,which
statesthat for any systemto be calleda relational databasemanagementsystem,the relational
capabilitiesmust be able to manageit completely.
For the rest of this appendix,I'll treat SQLServer2008specificallyasil relationaldatabase
engine,not in any of the other conligurationsin which it might be used,srLrch as a plain data store,a
document storagedevice,or whateverother way you might useSQLServeras a storageengine.
Rule1:TheInformation
Rule
AII information in the relationaldatabaseis represented
in exactlyoneand only onewary-by
ualuesin tables.
Rufe2: Guaranteed
AccessRule
Eachand,euerydatum (atomic ualue) is guaranteed to be logically accessibleby resorting to a
combinationof table name,primary keyualue,and column name.
This rule stressesthe importance of primary keysfor locating datain the database.The table name
locatesthe correcttable,the column name finds the correctcolumn, and the primary key'ualue
finds the row containing an individual dataitem of interest.In other words,each(atomic)pieceof
data is accessiblebythe combination of table name,primarykeyvalue, and column name.This
rule exactlyspecifieshowwe accessdatausing an accesslanguagesuch asTransact-SQl('I-SQL)
in SQLServer.
Using SQL,we can searchfor the primary key value (which is guaranteedto be unique,based
on relationaltheory aslong asit hasbeen defined),and oncewe havethe row, the datais irccessed
via the column name,We can alsoaccesqdataby any of the columns in the table,though vrearent
alwaysguaranteedto receivea singlerow back.
Rule3: Systematic
Treatment
of NULL
Values
NULL values(distinctfrom emptycharacterstring or a string of blank charactersand distinct
ftom rero or any other number)aresupportedin thefully relational RDBMSfor representing
missinginformation in a systematicway,independentof data type.
Rule4: Dynamic
Online Based
Gatalog onthe
Relational
Model
at the logical levelin thesameway as ordinary data,
Thedatabasedescriptionis represented
so authorizeduserscan apply thesamerelational languageto its interrogationas theyapply
to regular data.
, & C O D D '1S2 R U L EF
A P P E N DAI X SO R, A NR D B M S
Rule5: Gomprehensive
DataSublanguage
Rule
A relationalsystenxnxaysupportseuerallanguagesand variousmodesof terminal use.How-
ever, there must be at least one language whose statenxentsare expressible,per sonxe
well-definedsyntax,,as characterstringsand whoseability to support all of thefollowing is
comprehensible: a. data definition b. uiewdefinition c. data manipulation (interactiu'eand
by program)d. integrity constraintse.authorizntionf, ffansactionboundaries(begin,com-
mit, androllback).
Rule6:ViewUpdating
Rule
All uiewsthat are theoreticallyupdateablearealso updateableby thesystem.
Rule7: High-Level
Insert,
Update,
andlDelete
The capability of handling a baserelation or a deriued relation as a single operand aioplies
not only to the retrieualofdatabut also to the insertion,update,and deletionofdata.
Rule8: Physical
DataIndependence
Application prograrnsand,terminal activities remain logically unimpaired wheneverany
changesare made in eitherstoragerepresentationor accessmethods.
Applicationsmust still work using the samesyntax,evenwhen changes.ue madeto the way in
which the databaseinternally implementsdata storageand accessmethods.This nrle implies that
the way the data is storedphysicallymust be independentof the logical manner in which it's
accessed. This is sayingthat usersshouldn'tbe concernedabout how the datais storedor how
it's accessed.In fact, usersof the dataneed only be ableto get the basicdefinition of the datathey
need.
Other things that shouldnitaffectthe user'sview of the data areasfollows:
. Adding indexes:Indexesdeterminehow the data is stored,yet the user,through SQL,will
neverknow that indexesarebeing used.
. Changingthefilegroup of an objectlust moving a table to a new filegroupwill not affectthe
application.You accessthe data in the sameway no matter whereit is physicallylocated.
. Usingpartitioning: Beyondmoving entire tablesaround to different filegroups,yon can
moveparts ofa table around by using partitioning technologiesto spreadaccessaround to
different independent subsystemsto enhanceperformance,
. Modilying the storageengine:From time to time, Microsofthas to modiff how SQLServer
operates(especiallyin major versionupgrades).However,SQLstatementsmust appearto
accessthe data in the samemanner asthey did in any previousversion,only (wehope)
faster.
Rule9:Logical
DataIndependence
Application programsand terminal activitiesremain logically unimpaired when informa-
tion preservingchanges
of any kind that theoreticallypermit unimpairment are ma.deto the
basetables.
Along with rule 8, this rule insulatesthe user or application programfrom the low-levelimLplemen-
tation ofthe database.Together,they specifiithat specificaccessor storagetechniquesusedby the
RDBM$-and evenchangesto the structureof the tablesin the database-shouldnt affectthe
user'sability to work with the data.
In this way,if you add a column to a table and if tablesaresplit in a manner that doesnt add or
subtractcolumns,then the applicationprogramsthat call the databaseshouldbe unimpaired.
For exarnple,sayyou havethe table inFigureA-1.
baseTable
I baseTabletd
I
fcolriniil |
lcolumn2 I
FigureA-1.Small sampletable
baseTableA baseTableB
lbadTabtetd_-l
-l tbaseTabtetd_l
-l
lcolumnl lcolumn,
FigureA-2.Smallsampletablesplit into two tables
Rule10:Integrity
Independence
Integrityconstraintsspecificto a particular relationaldatabasemustbedefinablein the rela-
tional data sublanguageand storablein the catalog,not in theapplicationprograms.
Rule11: Distribution
lndependence
The data manipulation sublanguageof a relational DBMS must enableapplication pro-
gramsand terminal actiuitiesto rernain logically unimpaired whetherand wheneuerdata
arephysicallycentralizedor distributed.
Rule12:Non-Subversion
Rule
Ifa relational systemhas or supportsa low-level (single-record-at-a-tinxe) language',that
low-Ieuellanguagecannot be usedto subuertor bypassthe integrity rules or conshraints
expressed in the higher-leuel(multiple-records-at-a-time) relational languctge.
This rule requiresthat alternatemethods of accessingthe data arenot ableto bypassintegrity con-
straints,which meansthat userscant violate the rules of the databasein any way.For mosrtSQL
/-
,/
! I *C O D D '1S2 R U L EFSO RA NR D B M S
A P P E N DAI X
Summary
Codd's12rulesfor relational databasescan be usedto explain much about how SQLServerr oper-
atestoday.Theserules were a major stepforward in determiningwhether a databasevenclorcould
call his system"relational" and presentedstiff implementation challengesfor databasede'velopers.
Fifteenyearson, eventhe implementation of the most complexof theserulesis becomingJachiev-
able,though SQLServer(and other RDBMSs)still fall short of achievingall their objectives.