Feem ntau, cov txheej txheem database tau nruab nrog cov lus nug uas tuaj yeem pab nws cov neeg siv cov lus nug. Muaj ob hom xws li - kev sib raug zoo algebra thiab cov lej suav. Thawj yog cov lus nug txheej txheem uas siv cov piv txwv kev sib raug zoo raws li kev tawm tswv yim thiab tso tawm piv txwv kev sib raug zoo raws li cov zis. Siv unary lossis binary calculus rau qhov no. Relational algebra yog ua recursively thiab nruab nrab cov txiaj ntsig raug kho raws li kev sib raug zoo.
Cartesian khoom (Χ)
Muab cov ntaub ntawv los ntawm ob txoj kev sib raug zoo rau hauv ib qho.
Notation – r Χ s, qhov twg r thiab s yog qhov sib piv thiab lawv cov zis yuav raug txhais raws li
r Χ s={qt | q ∈ r thiab t ∈ s}.
Zoo. Teem kev sib raug zoo uas qhia txhua phau ntawv thiab cov ntawv sau nrog cov lus qhia.
Rename lag luam (ρ).
Kev sib raug zoo ntawm kev sib raug zoo algebra yog cov txiaj ntsig, tab sis tsis muaj npe. Kev hloov npe ua haujlwm tso cai rau koj hloov pauv tus nqi tso tawm, suav nrog tsab ntawv Greek me ρ.
Designation – ρ x (E), qhov twg cov txiaj ntsig ntawm qhov qhia E yog khaws cia nrog lub npex.
Kev ua haujlwm ntxiv:
- set hlaws;
- assignment;
- natural connection.
Kev suav lej
Nov yog cov lus nug uas tsis yog txheej txheem, txhais tau tias nws qhia koj yuav ua li cas tab sis tsis piav qhia yuav ua li cas. Cov kev suav txheeb txheeb muaj nyob rau hauv ob daim ntawv:
- kev sib txheeb ntawm ib tug tuple;
- filtering variable ranges.
Notation - T/State: Rov qab tag nrho T tuples uas txaus siab rau qhov xwm txheej. Kev tshwm sim. Rov qab tuples nrog lub npe. TRC tuaj yeem suav tau. Koj tuaj yeem siv existential (∃) thiab universal quantifiers (∀). Xaus. Cov lus nug saum toj no yuav muab cov txiaj ntsig zoo ib yam li yav dhau los.
Domain relational calculus DRC
Lub lim hloov pauv siv tus cwj pwm sau npe es tsis txhob tuple integer qhov tseem ceeb (raws li ua tiav hauv TRC tau hais los saum toj no).
Notation – {a 1, a 2, 3, …, a | P (a 1, 2, a 3, …, a)}, qhov twg a1, a2 yog tus cwj pwm thiab P qhia cov qauv tsim nrog tus nqi sab hauv.
Zoo. Teem cov kab lus, nplooj ntawv, thiab cov ncauj lus los ntawm TutorialsPoint kev sib raug zoo, qhov twg cov ntsiab lus yog cov ntaub ntawv.
Zoo li TRC, DRC kuj tuaj yeem sau tau siv cov khoom muaj txiaj ntsig thiab thoob ntiaj teb. DRC kuj suav nrog cov neeg ua haujlwm algebra kev sib raug zoo. Lub zog ntawm kev qhia ntawm kev suav, xam thiab kev sib raug zoo ntawm kev sib raug zoo ntawm cov ntsiab lus yog sib npaug.
Variations and schemes of relational calculus and algebra
Tus qauv ER, thaum lub tswv yim hauv cov duab kos, muab cov ntsiab lus zoo ntawm kev sib raug zoo tseem ceeb uas nkag siab yooj yim dua. Schematic sawv cev tuaj yeem ua raws li kev sib txheeb schema, piv txwv li lawv tuaj yeem tsim ua ke nrog ib leeg. Nws tsis tuaj yeem nqa tag nrho cov kev txwv ER rau hauv cov qauv kev sib raug zoo, tab sis cov qauv kwv yees tuaj yeem tsim tawm. Muaj ntau cov txheej txheem thiab algorithms muaj rau kev hloov cov kab kos rau qhov system no. Ib txhia ntawm lawv yog automated, thaum lwm tus yog tsim manually. ER kab kos feem ntau muaj cov hauv qab no:
- qhov chaw thiab nws cov cwj pwm;
- link, uas yog kev sib koom ua ke ntawm cov txiaj ntsig saum toj no.
Kev sib piv ntawm cov khoom thiab kev sib raug zoo tshwm sim nyob rau hauv ntau txoj kev thiab cov tswv yim. Piv txwv li, ib lub koom haum yog lub ntiaj teb tiag tiag cov khoom uas muaj qee yam cwj pwm. Cov txheej txheem sib txuam, cov algorithm yog raws li hauv qab no:
- tsim ib lub rooj rau txhua yam khoom;
- tus cwj pwm yuav tsum dhau los ua cov lus teb nrog cov ntaub ntawv sib xws;
- tshaj tawm tus yuam sij tseem ceeb.
Kev sib raug zoo yog kev sib koom ua ke ntawm cov koom haum. Cov txheej txheem muab tso ua ke yog raws li nram no:
- tsim lub rooj rau kev sib raug zoo;
- ntxiv cov yuam sij tseem ceeb ntawm txhua qhov chaw koom nrog ua cov lus teb nrog cov ntaub ntawv tsim nyog;
- yog tias kev sib raug zoo muaj tus cwj pwm, teeb tsa txhua tus cwj pwm raws li lub rooj teb;
- sib txuas tus yuam sij tseem ceeb uas tsim txhua yamtus so rau cov khoom koom;
- qhia tag nrho cov kev txwv txawv teb chaws.
Kev nthuav tawm ntawm cov teeb tsa tsis muaj zog thiab cov khoom hierarchical tshwm sim raws li qee qhov system. Ua ntej tshaj plaws, nws yog ib qho tsim nyog yuav tsum nkag siab txog lub hauv paus tseem ceeb thiab cov ntsiab lus ntawm cov txiaj ntsig no. Lub teeb tsis muaj zog yog ib qho uas tsis muaj qhov tseem ceeb cuam tshuam nrog nws. Cov txheej txheem zaub yog raws li nram no:
- tsim lub rooj rau cov khoom tsis muaj zog;
- ntxiv tag nrho cov cwj pwm rau lub schema ua ib daim teb;
- qhia tus yuam sij tseem ceeb rau kev txheeb xyuas;
- set tag nrho cov kev txwv txawv teb chaws.
Kev nthuav tawm ntawm cov khoom hierarchical raws li kev tshwj xeeb lossis kev nthuav dav ntawm cov lus ntawm kev sib raug zoo algebra tshwm sim nyob rau hauv daim ntawv ntawm cov khoom sib txuas. Lub algorithm yog raws li nram no:
- tsim cov rooj rau txhua yam khoom qib siab dua;
- ntxiv tus yuam sij;
- ntawm qib qis siv tag nrho lwm yam khoom ntawm qib qis;
- tshaj tawm cov yuam sij tseem ceeb ntawm lub rooj;
- set txawv teb chaws tseem ceeb txwv.
Muaj kev xaiv piav qhia, khaws cia, hloov cov ntaub ntawv
SQL yog ib hom lus programming rau kev sib txheeb databases. Nws yog tsim los ntawm algebra thiab correlation calculus ntawm tuples. SQL los ua ib pob nrog txhua qhov loj DBMS kev faib tawm. Muaj cov ntaub ntawv thiab hom lus rau kev tswj hwm lawv. Los ntawm kev siv kev sib raug zoo algebra SQL cov ntaub ntawv txhais cov khoom, koj tuaj yeem tsim thiab hloov kho cov txheej txheem database,thaum cov kev tswj hwm thiab kev hloov pauv, nrog rau cov ntaub ntawv hloov pauv, tso cai rau koj khaws thiab khaws cov ntaub ntawv tau teeb tsa hauv qhov system. Siv cov lus txib nram qab no los txhais cov qauv thiab cov kab ke:
- tsim cov ntaub ntawv tshiab, cov ntxhuav thiab kev pom los ntawm DBMS.
- throws commands.
- hloov lub database schema.
- qhov lus txib no ntxiv tus cwj pwm rau ib txoj hlua khoom.
SQL yog nruab nrog Cov Ntaub Ntawv Manipulation Language (DML). Nws hloov kho cov ntaub ntawv piv txwv los ntawm kev ntxig, hloov kho, thiab tshem tawm cov ntaub ntawv. DML yog lub luag haujlwm rau hloov tag nrho cov ntaub ntawv. SQL muaj cov lus txib hauv qab no hauv ntu DML:
- SELECT yog ib qho ntawm cov lus nug yooj yim commands. Nws yog qhov zoo sib xws rau kev ua haujlwm ntawm kev sib raug zoo algebra. Nws xaiv cov cwj pwm raws li cov xwm txheej tau piav qhia hauv WHERE clause.
- NTAWM - Nqe lus no siv lub npe los ntawm kev sib cav los ntawm cov yam ntxwv yuav raug xaiv / npaj. Yog hais tias muaj ntau tshaj ib lub npe, cov khoom no sib raug rau cov khoom Cartesian.
- WHERE - Tshooj lus no qhia txog qhov ua piv txwv lossis cov xwm txheej uas yuav tsum tau ua kom thiaj li tsim nyog tau txais tus yam ntxwv.
Tsi muaj lus txib:
- insert;
- hloov tus nqi;
- delete.
Creating Relational Algebra Queries
Thaum tsim kev tshawb nrhiav, txoj haujlwm yog nrhiav cov qauv ntawm kev ua haujlwm uas yuav ua rau muaj qhov tseeb. Cov haujlwm tseem ceeb ntawm kev sib raug zoo algebra yog qhov yooj yimkev ua haujlwm nrog ib lossis ob qhov kev sib raug zoo li operands. Kev sib xyaw ua ke ntawm cov kab ke txiav txim siab qhov kawg tshwm sim. Txij li cov txheej txheem ntawm kev sib raug zoo algebra hauv databases yog qhov yooj yim heev, ntau cov txiaj ntsig nruab nrab tuaj yeem tau txais ua ntej mus txog qhov kawg tso zis, lawv kuj tau siv los ua cov neeg ua haujlwm uas tsim cov ntaub ntawv tshiab tau txais.
Rau cov neeg ua haujlwm feem ntau, qhov kev txiav txim ntawm cov lus nug thiab lawv qhov kev ua tiav tsis muaj teeb meem, uas txhais tau hais tias tib cov zis tuaj yeem ua tiav los ntawm kev tsim thiab sib txuas cov ntaub ntawv nruab nrab hauv ntau txoj kev. Hauv kev xyaum, kev tshawb nrhiav database yog yooj yim heev. Lub kaw lus rau kev ua haujlwm thiab cov txiaj ntsig nruab nrab yog txiav txim siab los ntawm cov lus nug optimizer. Thaum tsim cov lus nug, cov kev xav tau, koj yuav tsum
ua ntej xaiv qhov kev sib raug zoo uas tsim nyog kom ua tiav cov lus teb, thiab tom qab ntawd qhia cov haujlwm thiab cov txiaj ntsig nruab nrab. Cov qauv ntawm kev sib raug zoo algebra query hauv cov ntaub ntawv tau txais tuaj yeem sawv cev raws li daim duab. Cov kev xav tau optimizers sim teeb tsa kev ua tiav kom zoo li sai tau. Hauv kev xyaum, qhov no feem ntau txhais tau hais tias lawv sim txo cov txiaj ntsig nruab nrab kom sai li sai tau. Cov piv txwv ntawm kev sib raug zoo algebra yuav pab nrog qhov no.
Example 1.
Cov Ntaub Ntawv Xav Tau: Cov ntaub ntawv ntawm xyoo 1996 cov tsheb uas muaj qhov tsis zoo thaum kuaj xyuas xyoo 1999.
Ua ntej, cov ntaub ntawv hais txog lub tsheb raug tso tawm kom nkag siab txog qhov tseem ceeb ntawm txhua tus cwj pwm ntawm kev sib raug zoo. Cov ntaub ntawv hais txog kev tshuaj xyuas yog khaws cia rau hauv lub rooj "Kev Tshuaj Xyuas", thiab yog tias kuaj pomfaults, lawv raug kaw nyob rau hauv lub "Problem" rooj. Yog li, peb lub rooj no yuav tsum tau txais cov ntaub ntawv xav tau.
Tsuas yog 1996 lub tsheb txaus nyiam. Tus qauv ntau yam ntawm lub tsheb yog sawv cev raws li tus nqi ntawm lub teeb attribute nyob rau hauv kab ntawm lub tsheb cov ntaub ntawv rooj. Thawj qhov tshwm sim nruab nrab muaj cov tuples sawv cev rau xyoo 1996.
Yog li cov kab uas npog lub sijhawm no tsuas yog xav tau. Koj yuav tsum tau siv ib qho kev xaiv kom rho tawm lawv. Tam sim no muaj tsheb thiab tshuaj xyuas uas yuav tsum tau ua. Tom qab ntawd cov hlua txuas txuas nrog kev ua haujlwm sib txuas. Lawv yuav tsum tau koom nrog tus lej sau npe, vim nws tsuas yog kab ke xwb, ib qho kev koom ua ke yog siv.
Yuav kom paub seb puas muaj teeb meem thaum kuaj xyuas, koj yuav tsum koom nrog cov kab teeb meem nrog daim tshev. Tom qab txuas cov kab tswj mus rau cov tsheb, koj tuaj yeem txuas qhov tshwm sim no rau lub rooj ua txhaum. Qhov kev koom tes yuav tsum yog nyob ntawm tus lej sau npe thiab hnub uas tau lees paub. Cov no tsuas yog cov kab ke hauv cov rooj xwb, yog li kev koom nrog ntuj raug siv.
Xaiv kev xaiv yam tsis muaj qhov tshwm sim nruab nrab
Example 2.
Cov ntaub ntawv xav tau: Tus tsav tsheb lub npe rau cov qauv xyoo 1995 lossis cov tsheb loj dua uas tsis tau sim rau xyoo 2000. Lub npe yog nyob rau hauv lub rooj "Tsav Tsheb". Cov koom haum tub ceev xwm tau piav qhia nyob rau hauv cov lus "Kev tshuaj xyuas thiab cov tsheb hauv lub tsev noj mov". Yog liYog li, peb lub rooj no xav tau. Ua ntej, koj yuav tsum nrhiav cov tsheb uas tsis tau kuaj xyuas rau xyoo 2000. Nws tsis tuaj yeem daws qhov teeb meem no tsuas yog siv cov kev tshuaj xyuas uas tau teev tseg hauv lub rooj, vim nws muaj cov ntaub ntawv hais txog cov kev tshuaj xyuas uas tau ua, thiab tsis yog cov uas tsis tau siv. Qhov teeb meem no daws tau los ntawm kev nrhiav cov tsheb sib txuas uas tau kuaj xyuas ua ntej xyoo 2000. Qhov tseeb, tsuas yog xav tau lawv cov lej sau npe xwb.
Tseem muaj lwm yam piv txwv ntxiv nrog rau cov saum toj no uas qhia tias yuav hloov pauv lossis nrhiav cov ntaub ntawv li cas. Cov lus nug txawv tuaj yeem ua kom zoo dua siv cov haujlwm tshwj xeeb. Qhov tseeb, txhawm rau tshawb nrhiav thiab nrhiav cov ntaub ntawv kom yooj yim thiab yooj yim li sai tau, muaj cov qauv lej sib txheeb.
Qhov twg cov ntaub ntawv muaj kev nyab xeeb thiab tiv thaiv
Cov ntaub ntawv sib raug zoo ntawm kev sib raug zoo algebra yog khaws cia hauv cov ntaub ntawv tawm tswv yim uas muaj cov ntaub ntawv. Nyob rau theem ntawm lub cev, cov ntaub ntawv tiag tiag raug kho nyob rau hauv hom electromagnetic ntawm qee lub cuab yeej. Cov cuab yeej khaws cia no tuaj yeem muab faib ua peb pawg:
- Pib. Pawg no suav nrog kev nco uas tuaj yeem nkag ncaj qha rau CPU. Cov ntawv sau npe, ceev ceev (cache) thiab lub cim xeeb tseem ceeb (RAM) tau ncaj qha mus rau lub hauv paus, vim lawv txhua tus nyob ntawm lub motherboard lossis chipset. Qhov kev khaws cia no feem ntau me me heev, ceev ceev, thiab tsis ruaj khov. Yuav tsum muaj hluav taws xob tas li los tswj lub xeev. Yog tias nws ua tsis tiav, tag nrho nws cov ntaub ntawv yuav ploj.
- Secondary. Siv los khaws cov ntaub ntawv rau yav tom ntejsiv los yog thaub qab. Xws li cov khoom siv nco uas tsis yog ib feem ntawm cov processor chipset lossis motherboard, xws li cov khoom sib nqus, cov khoom siv kho qhov muag (DVDs, CDs, thiab lwm yam), hard drives, flash drives, thiab cov ntaub nplaum sib nqus.
- Tertiary. Siv los khaws cov ntaub ntawv ntau heev. Txij li thaum xws li cov khoom siv cia yog sab nraud rau lub computer system, lawv yog qhov qeeb tshaj plaws ntawm kev ceev. Cov gadgets cia no feem ntau yog siv los thaub qab tag nrho cov kab ke. Optical discs thiab magnetic tapes yog dav siv los ua tertiary cia.
Kev sib raug zoo tshwj xeeb ntawm kev ua lej lej yog qhov tseem ceeb rau kev nug txog kev ua haujlwm zoo.
Storage structure
Lub khoos phis tawj muaj lub cim xeeb zoo raws hierarchy. CPU muaj kev nkag ncaj qha mus rau lub ntsiab system nrog rau cov ntawv sau npe. Lub cim xeeb tseem ceeb nkag lub sij hawm yog pom tseeb tsawg dua processor ceev. Txhawm rau txo qhov tsis sib xws, ib lub cache tau qhia. Lub cache muab lub sijhawm nkag tau sai tshaj plaws thiab muaj cov ntaub ntawv uas nquag nkag los ntawm CPU.
Lub cim xeeb nrog kev nkag ceev tshaj plaws yog qhov kim tshaj plaws. Cov cuab yeej cia loj muab kev ceev me ntsis thiab pheej yig dua, tab sis lawv tuaj yeem khaws cov ntaub ntawv loj loj piv rau cov ntawv sau npe lossis cache.
Sib nqus thiab hard drives yog cov khoom siv thib ob feem ntau hauv cov tshuab computer niaj hnub no. Lawv hu ua magnetichlau puag. Cov disks no tau muab tso rau hauv vertically ntawm spindle. Lub taub hau nyeem / sau txav ntawm lawv thiab siv los ua kom muaj zog lossis tshem tawm qhov chaw hauv qab no. Nws tuaj yeem lees paub tias yog 0 (zero) lossis 1 (ib qho).
Hard drives yog formatted nyob rau hauv ib tug zoo-txhais kev txiav txim kom txuag tau cov ntaub ntawv. Nws muaj ntau concentric voj voog hu ua paths. Txhua qhov kev sib txuas ntxiv tau muab faib ua ntu, feem ntau khaws 512 bytes ntawm cov ntaub ntawv.
Cov haujlwm ua haujlwm
Kev ua haujlwm ntawm kev sib raug zoo ntawm cov lus algebra thiab nws cov ntaub ntawv tuaj yeem muab faib ua ob pawg:
- update;
- search.
Thawj qeb hloov cov ntaub ntawv muaj nuj nqis los ntawm kev ntxig, tshem tawm lossis hloov kho tshiab. Ntawm qhov tod tes, kev tshawb nrhiav haujlwm tsis hloov kho cov ntaub ntawv, tab sis rho tawm nws tom qab xaiv qhov kev lim dej. Hauv ob hom kev ua haujlwm, kev xaiv ua lub luag haujlwm tseem ceeb. Ntxiv rau kev tsim thiab tshem tawm cov ntaub ntawv, tej zaum yuav muaj ntau yam haujlwm uas tuaj yeem ua rau lawv:
- Qhib - muaj nyob rau hauv ib qho ntawm ob hom kev nyeem lossis sau ntawv. Hauv thawj kis, lub operating system tsis tso cai rau leej twg hloov cov ntaub ntawv. Hauv lwm lo lus, cov ntaub ntawv tsuas yog nyeem. Cov ntaub ntawv qhib hauv hom nyeem tuaj yeem sib koom ntawm ntau yam khoom. Hom kev sau cia koj hloov cov ntaub ntawv. Cov ntaub ntawv tuaj yeem nyeem tau tab sis tsis tuaj yeem muab faib.
- Kaw yog qhov tseem ceeb tshaj plaws ntawm kev ua haujlwm ntawm qhov kev pom zoo vim nws tshem tawm tag nrho cov xauv(yog tias nyob hauv hom sib koom), txuag cov ntaub ntawv (yog tias hloov kho) rau cov xov xwm thib ob, thiab tso tawm tag nrho cov buffers thiab cov neeg ua haujlwm cuam tshuam nrog cov ntaub ntawv.
- Indexing yog ib txoj hauv kev qhia cov ntaub ntawv rau kev rho tawm cov ntaub ntawv los ntawm cov ntaub ntawv ntawm lub kaw lus raws li qee tus cwj pwm uas lub kaw lus tau siv. Txhais raws li tus cwj pwm.
Indexing tuaj yeem yog hom hauv qab no:
- Primary yog txhais nyob rau hauv cov ntaub ntawv txiav txim. Cov ntaub ntawv xov xwm raug teeb tsa hauv thaj chaw tseem ceeb.
- Secondary index generated los ntawm ib daim teb uas yog tus neeg sib tw tus yuam sij thiab muaj tus nqi tshwj xeeb hauv txhua cov ntaub ntawv lossis tsis yog tus yuam sij uas muaj qhov sib npaug.
- Clustering yog txhais nyob rau hauv ib qho kev txiav txim cov ntaub ntawv, nyob rau hauv ib tug tsis tseem ceeb teb.
A database management system lossis DBMS yog hais txog kev siv tshuab khaws cia thiab khaws cov ntaub ntawv cov neeg siv nrog kev ua haujlwm siab tshaj plaws nrog rau kev ntsuas kev nyab xeeb tsim nyog. Kev soj ntsuam ze dua ntawm qhov teeb meem no ua rau qhov xaus tias kev sib raug zoo algebra yog ib hom lus ntawm cov tswv lag luam uas coj kev sib raug zoo raws li kev sib cav thiab xa lawv rov qab los ntawm qhov tshwm sim.