Dab tsi yog referential kev ncaj ncees hauv SQL Server?
Dab tsi yog referential kev ncaj ncees hauv SQL Server?

Video: Dab tsi yog referential kev ncaj ncees hauv SQL Server?

Video: Dab tsi yog referential kev ncaj ncees hauv SQL Server?
Video: Tsis Yog Hmoob Sib Ntxhais Ntxawm - SODA Poj Laib Khej Me (Cover) 2024, Hlis ntuj nqeg
Anonim

Raws li Relational Database Management System (RDBMS), SQL Server siv cov referential kev ncaj ncees kev txwv kom ntseeg tau tias cov ntaub ntawv hauv ib lub rooj taw qhia rau cov ntaub ntawv hauv lwm lub rooj-thiab tsis taw tes rau cov ntaub ntawv uas tsis muaj nyob. SQL Server siv cov kev txwv, ua rau, kev cai, thiab kev ua txhaum cai los tswj referential kev ncaj ncees.

Kuj tseem yuav paub yog, dab tsi yog qhov kev ntseeg ncaj ncees hauv cov ntaub ntawv?

Referential kev ncaj ncees hais txog qhov raug thiab sib xws ntawm cov ntaub ntawv hauv kev sib raug zoo. Hauv kev sib raug zoo, cov ntaub ntawv txuas ntawm ob lossis ntau lub rooj. Yog li ntawd, referential kev ncaj ncees xav kom, thaum twg tus nqi tseem ceeb txawv teb chaws siv nws yuav tsum siv tau, uas twb muaj lawm tus yuam sij tseem ceeb hauv cov lus niam txiv.

Kuj Paub, koj txhais li cas los ntawm kev txwv kev ncaj ncees? A referential integrity txwv txhais tau tias yog ib feem ntawm kev sib koom ua ke ntawm ob hom chaw. Cov txhais rau a referential integrity txwv qhia cov ntaub ntawv hauv qab no: Lub ntsiab lus kawg ntawm qhov txwv . (Ib hom chaw uas nws qhov chaw tseem ceeb raug xa mus los ntawm qhov kawg ntawm kev vam meej.)

Tsis tas li ntawd, qhov kev ncaj ncees kev ncaj ncees piav qhia nrog tus qauv tsim nyog yog dab tsi?

Referential kev ncaj ncees Nws txhais tau hais tias kev siv los ntawm kab hauv ib lub rooj mus rau lwm lub rooj yuav tsum siv tau. Piv txwv ntawm referential kev ncaj ncees Kev txwv nyob rau hauv Cov Neeg Siv Khoom / Kev Txiav Txim database ntawm Lub Tuam Txhab: Cov Neeg Siv Khoom (CustID, CustName) Order (OrderID, CustID, OrderDate)

Yuav ua li cas hais txog kev ncaj ncees nyob rau hauv SQL?

Referential Integrity yog ib qho kev txwv hauv database uas tswj kev sib raug zoo ntawm ob lub rooj. Cov Referential Integrity kev txwv yuav tsum muaj qhov tseem ceeb hauv kab ntawv tseem ceeb txawv teb chaws yuav tsum muaj nyob rau hauv thawj tus yuam sij uas tau hais los ntawm tus yuam sij txawv teb chaws lossis lawv yuav tsum yog null.

Pom zoo: