Ib ib-rau-ntau txoj kev sib raug zoo hauv cov ntaub ntawv tshwm sim thaum txhua cov ntaub ntawv hauv Table A yuav muaj ntau cov ntaub ntawv txuas hauv Table B, tab sis txhua cov ntaub ntawv hauv Table B yuav tsuas muaj ib cov ntaub ntawv sib xws hauv Table A.
Kev sib raug zoo ib-rau-ntau hauv cov ntaub ntawv yog qhov kev sib raug zoo tshaj plaws ntawm cov ntaub ntawv tsim thiab yog lub hauv paus ntawm kev tsim zoo.
Databases kuj tuaj yeem siv kev sib raug zoo ib leeg thiab ntau qhov kev sib raug zoo.
Piv txwv ntawm Ib-rau-Muaj Kev Sib Raug Zoo
Xav txog kev sib raug zoo ntawm tus kws qhia ntawv thiab cov chav kawm uas lawv qhia. Tus kws qhia ntawv tuaj yeem qhia ntau chav, tab sis chav kawm yuav tsis muaj kev sib raug zoo nrog tus xibfwb.
Yog li ntawd, rau txhua cov ntaub ntawv nyob rau hauv Cov Xib Fwb lub rooj, yuav muaj ntau cov ntaub ntawv nyob rau hauv Cov Lus Qhia. Qhov piv txwv no qhia txog kev sib raug zoo ib leeg rau ntau tus: ib tus kws qhia ntawv rau ntau qhov kev kawm.
Vim li cas thiaj tsim kev sib raug zoo ib leeg rau ntau qhov tseem ceeb
Txhawm rau sawv cev rau kev sib raug zoo ib-rau-ntau, koj xav tau tsawg kawg ob lub rooj. Cia peb saib yog vim li cas.
Ua raws li Thawj Daim Ntawv Tsim Qauv
Tej zaum peb tsim ib lub rooj uas peb xav sau npe thiab cov chav kawm qhia. Tej zaum peb yuav tsim ib tug Xib Fwb thiab Chav Kawm cov lus zoo li no:
Teacher_ID | Teacher_Name | Course |
---|---|---|
Teach_001 | Carmen | Biology |
Tshaj_002 | Veronica | Math |
Tshaj_003 | Jorge | English |
Yuav ua li cas yog Carmen qhia ob lossis ntau qhov kev kawm? Peb muaj ob txoj kev xaiv nrog qhov tsim no. Peb tuaj yeem ntxiv nws rau Carmen cov ntaub ntawv uas twb muaj lawm, zoo li qhov no:
Teacher_ID | Tshaj tawm_Npe | Course |
---|---|---|
Teach_001 | Carmen | Biology, lej |
Tshaj_002 | Veronica | Math |
Tshaj_003 | Jorge | English |
Txawm li cas los xij, tus qauv tsim saum toj no tsis yooj yim thiab tuaj yeem ua rau muaj teeb meem tom qab thaum koj ntxig, kho, lossis tshem tawm cov ntaub ntawv. Nws ua rau nws nyuaj rau kev tshawb nrhiav cov ntaub ntawv.
Tus qauv tsim no tseem ua txhaum thawj txoj cai ntawm cov ntaub ntawv normalization, First Normal Form (1NF), uas tau hais tias txhua lub xov tooj ntawm tes yuav tsum muaj cov ntaub ntawv sib cais.
Txoj Cai Thib Ob Txoj Cai
Lwm qhov kev tsim qauv yuav yog ntxiv cov ntaub ntawv thib ob rau Carmen:
Tswv _ID | Tshaj tawm_Npe | Course |
---|---|---|
Teach_001 | Carmen | Biology |
Teach_001 | Carmen | Math |
Tshaj_002 | Veronica | Math |
Tshaj_003 | Jorge | English |
Txoj hauv kev no ua raws li 1NF tab sis tseem tsis zoo tsim cov ntaub ntawv vim nws qhia txog kev rov ua dua thiab tuaj yeem ua rau cov ntaub ntawv loj loj yam tsis tsim nyog. Qhov tseem ceeb tshaj, cov ntaub ntawv tuaj yeem ua tsis sib xws.
Piv txwv li, yuav ua li cas yog Carmen hloov lub npe? Ib tus neeg ua haujlwm nrog cov ntaub ntawv tuaj yeem hloov kho nws lub npe hauv ib cov ntaub ntawv thiab tsis hloov kho nws hauv cov ntaub ntawv thib ob.
Tus qauv tsim no ua txhaum Txoj Cai Thib Ob (2NF) tus qauv, uas ua raws li 1NF thiab yuav tsum zam qhov rov ua dua ntawm ntau cov ntaub ntawv. Txoj cai 2NF ua tiav qhov no los ntawm kev sib cais subsets ntawm cov ntaub ntawv mus rau ntau lub rooj thiab tsim kev sib raug zoo ntawm lawv.
Yuav Ua Li Cas Tsim Cov Ntaub Ntawv Nrog Ib-rau- Ntau Kev Sib Raug Zoo
Txhawm rau ua kom muaj kev sib raug zoo ib-rau-ntau ntawm cov Xib Fwb thiab Cov Ntawv Kawm, rhuav cov rooj ua ob thiab txuas lawv siv tus yuam sij txawv teb chaws.
Ntawm no, peb tshem tawm cov kab ntawv Kawm hauv Cov Xib Fwb lub rooj:
Tswv _ID | Tshaj tawm_Npe |
---|---|
Teach_001 | Carmen |
Tshaj_002 | Veronica |
Tshaj_003 | Jorge |
Thiab ntawm no yog Lub Rooj Sib Tham. Nco ntsoov tias nws tus yuam sij txawv teb chaws, Teacher_ID, txuas ib chav kawm rau tus kws qhia ntawv hauv Xib Fwb lub rooj:
Course_ID | Course_Name | Teacher_ID |
---|---|---|
Course_001 | Biology | Teach_001 |
Course_002 | Math | Teach_001 |
Course_003 | English | Tshaj_003 |
Peb tau tsim kev sib raug zoo ntawm Cov Xib Fwb thiab Lub Rooj Sib Tham uas siv tus yuam sij txawv teb chaws. Qhov kev npaj no qhia peb Carmen qhia ob qho tib si Biology thiab lej thiab Jorge qhia lus Askiv.
Peb tuaj yeem pom yuav ua li cas qhov kev tsim no zam tsis pub muaj kev rov ua dua tshiab, tso cai rau tus kws qhia ntawv los qhia ntau yam kev kawm, thiab siv kev sib raug zoo ib-rau-ntau.