1NF, 2NF, 3NF, BCNF

Normal forms એક સીડી છે: 1NF દરેક cell ને એક value રખાવે છે, 2NF એક composite key પર partial dependencies કાઢે છે, 3NF transitive dependencies કાઢે છે, અને BCNF 3NF ને કસે છે જેથી દરેક determinant એક key હોય.

12 min read · 10 cards · 2 checks

Read in: English · हिन्दी · ગુજરાતી


Theory

ઇલાજ, એક વખતે એક પગલું

Meera ના ગંદા table માં ત્રણેય anomalies છે. ઇલાજ, normalization, એક છલાંગ નથી પણ તબક્કાઓની એક સીડી છે જેને normal forms કહે છે: 1NF, પછી 2NF, પછી 3NF, પછી BCNF. દરેક પગલું એક ખાસ પ્રકારની ખરાબ design કાઢે છે જેને તમે હવે ઓળખો છો.

તમે એમને ક્રમમાં ચઢો છો, એક table 2NF માં હોય એ પહેલા એ 1NF માં હોવું જોઈએ, અને એ જ રીતે. ટોચ સુધી, anomalies જતા રહે છે અને દરેક તથ્ય બરાબર એક જગ્યાએ રહે છે. આ Unit 3 નો ભવ્ય સમાપન છે, અને એક પાક્કો exam સવાલ.

Theory

એક ઓરડાને passes માં સાફ કરવો

તમે એક ગંદા ઓરડાને એક જ હલનચલનમાં સાફ નથી કરતા. પહેલો pass: દરેક ઢીલી વસ્તુ ને એની ખુદની જગ્યાએ મૂકો, કંઈ ઢગલામાં નહીં (1NF). બીજો pass: જે વસ્તુઓ અહીં ફક્ત અડધી છે એમને ત્યાં ખસેડો જ્યાં એ પૂરી રીતે છે (2NF). ત્રીજો pass: એ વસ્તુઓ કાઢો જે ખરેખર ઓરડાની કોઈ બીજી વસ્તુ વિશે છે (3NF). દરેક pass એક ખાસ પ્રકારની ગંદકી ને નિશાન બનાવે છે, અને તમે એમને હંમેશા ક્રમમાં કરો છો.

At a glance

normal-form સીડી

Formકાઢે છેનિયમ
1NFMulti-valued / composite cellsદરેક cell એક atomic value રાખે છે
2NFPartial dependency1NF + કોઈ non-key એક composite key ના ભાગ પર નિર્ભર નહીં
3NFTransitive dependency2NF + કોઈ non-key બીજા non-key ને determine ન કરે
BCNFબચેલી determinant anomaliesદરેક determinant એક super key છે

Theory

સીડી ચઢવી

  • 1NF: દરેક cell એક single atomic value રાખે છે. Meera નું 'એક cell માં ત્રણ phone numbers' એનું ઉલ્લંઘન કરે છે; ઇલાજ phones ને એમની ખુદની rows/table માં વહેંચવો. કોઈ repeating groups નહીં.
  • 2NF: 1NF માં અને કોઈ partial dependency નહીં, કોઈ non-key attribute એક composite key ના ફક્ત ભાગ પર નિર્ભર નહીં. ફક્ત ત્યારે મહત્વનું જ્યારે key composite હોય. ઇલાજ: partial attribute ને એની ખુદની table માં ખસેડો.
  • 3NF: 2NF માં અને કોઈ transitive dependency નહીં, કોઈ non-key attribute બીજા non-key દ્વારા determine નહીં (customer_id ના દ્વારા customer_city). ઇલાજ: શૃંખલા ને બહાર વહેંચો.
  • BCNF: એક કડક 3NF, દરેક dependency X to Y માટે, X એક super key હોવો જોઈએ (દરેક determinant એક key છે).

Quiz

Meera નું table એક item નું supplier_city store કરે છે, જે supplier_id (એક non-key column) પર નિર્ભર છે, table ની key પર નહીં. કયો normal form આને ઠીક કરે છે, અને કેવી રીતે?

  1. 3NF, transitive dependency ને એક અલગ Supplier table માં કાઢીને
  2. 1NF, cells ને atomic બનાવીને
  3. 2NF, એક partial dependency કાઢીને
  4. એ પહેલેથી સંપૂર્ણપણે normalized છે
Show the answer

3NF, transitive dependency ને એક અલગ Supplier table માં કાઢીને

supplier_city, supplier_id પર નિર્ભર છે, એક non-key attribute, તો એ એક transitive dependency છે, બરાબર એ જ જે 3NF કાઢે છે. ઇલાજ: supplier_id અને supplier_city ને એમની ખુદની Supplier table માં ખસેડો, એક foreign key થી પાછી જોડાયેલી. 1NF atomic cells વિશે છે અને 2NF એક composite key પર partial dependencies વિશે, કોઈ પણ એક non-key-determines-non-key શૃંખલા સાથે મેળ ખાતું નથી.

Think first

2NF ને composite key કેમ જોઈએ

એક partial dependency નો અર્થ એક non-key attribute key ના ફક્ત ભાગ પર નિર્ભર છે. આના વિશે વિચારો: જો એક table ની primary key એક એકલો column હોય, તો શું એક partial dependency મોજૂદ પણ હોઈ શકે? એ તમને શું કહે છે કે 2NF ક્યારે મહત્વનું છે?

Show the answer

ના, એક single-column key ના 'ભાગ' નથી હોતા જેના પર partially નિર્ભર થવાય, તો એક single-column primary key વાળી table જે પહેલેથી 1NF માં છે આપોઆપ 2NF માં છે. Partial dependencies ફક્ત એક composite key સાથે ઊભી થઈ શકે (જેમ કે order_id + item_id), જ્યાં એક column ફક્ત order_id પર નિર્ભર હોઈ શકે. તો 2NF ફક્ત ત્યારે અસલી કામ કરે છે જ્યારે key composite હોય, એક સૂક્ષ્મ મુદ્દો જેને examiners ટટોળવો ગમે છે.

Watch out

Marks ક્યાં કપાય છે

કયો form શું ઠીક કરે છે એ ભેળવવું: 1NF = atomic values, 2NF = કોઈ partial dependency નહીં (ફક્ત composite key), 3NF = કોઈ transitive dependency નહીં, BCNF = દરેક determinant એક super key છે. એ ભૂલવું કે forms સંચિત છે (2NF ને 1NF જોઈએ, વગેરે). અને નિયમ fix વગર આપવો (એક જોડાયેલી table માં decompose). સીડી નો ક્રમ અને દરેક form જે ખાસ dependency કાઢે છે, એ exam ના મુખ્ય નિશાન છે.

Formula

Exam recipe: આ table ને normalize કરો

ઉપરની તરફ કામ કરો, દરેક પગલું બતાવતા: 1NF તપાસો (atomic cells, કોઈ multi-valued ને વહેંચો), પછી 2NF (partial dependencies કાઢો, ફક્ત જો composite key), પછી 3NF (non-key columns ના દ્વારા transitive dependencies કાઢો), દરેક પગલે જે dependency તમે ખતમ કરો છો અને જે નવી table બનાવો છો એનું નામ આપતા. BCNF જો એક determinant એક key ન હોય. દરેક તબક્કે decomposition બતાવો, એ કરેલી પ્રગતિ જ પૂરા marks કમાવે છે.

Theory

Unit 3 પૂરું, Meera તૈયાર છે

Meera ની અંધાધૂંધ sheet હવે tables નો એક સાફ સેટ છે, Customers, Items, Suppliers, Orders, દરેક તથ્ય એક જગ્યાએ, anomalies જતા રહ્યા. એ એક અસલી relational database design છે. Unit 4 આખરે એને (અને તમને) એની સાથે SQL માં વાત કરવા દે છે: આ tables બનાવવી, data insert કરવો, અને સવાલો પૂછવા. અહીં તમે જે design કર્યું એ આગળ કંઈક બને છે જે તમે type કરશો. આગળ: SQL data types અને CREATE statement.

Summary

Key takeaways

  • Normal forms એક સંચિત સીડી છે: દરેક ને પાછલું જોઈએ.
  • 1NF: દરેક cell એક single atomic value રાખે છે (કોઈ multi-valued કે repeating cells નહીં).
  • 2NF: 1NF + કોઈ partial dependency નહીં (non-key એક composite key ના ભાગ પર નિર્ભર); ફક્ત composite keys સાથે મહત્વનું.
  • 3NF: 2NF + કોઈ transitive dependency નહીં (non-key બીજા non-key દ્વારા determine).
  • BCNF: કડક 3NF, દરેક determinant એક super key હોવો જોઈએ.
  • દરેક ઉલ્લંઘન ને એક key થી જોડાયેલી અલગ table માં decompose કરીને ઠીક કરો.
  • યાદ રાખવાની યુક્તિ: ઓરડાને passes માં સાફ કરો, atomic, અડધું-અહીં, કોઈ-બીજા-વિશે.

Study this properly

This page is the lesson to read. In Gri-Learn the same topic is a graded deck: the self-checks are scored and your weak topics are tracked. Free to start.

Start this topic

Already have an account? Sign in

More from Concepts of Database

Gri-Learn · syllabus-mapped B.C.A. lessons in English, Hindi and Gujarati

1NF, 2NF, 3NF, BCNF · Data Processing and Analysis (DPA) · Gri-Learn