Theory
બનાવતાં પહેલાં design
Meera નો ભત્રીજો એની દુકાનનું database બનાવવાનો છે. એક સારો builder ઈંટો આડેધડ મૂકતો નથી, એ પહેલા એક plan દોરે છે.
Databases માટે, એ plan એક E/R diagram છે, અને એ બસ ત્રણ પ્રકારના ટુકડા થી બનેલો છે: એ વસ્તુઓ જેને તમે store કરો છો, એમની વિગતો, અને એ કેવી રીતે જોડાય છે. આ ત્રણેયને કાગળ પર સાચા કરી લો અને tables લગભગ જાતે લખાઈ જાય છે.
અને એમને શોધવાનો એક સરસ shortcut છે: એ business નું વર્ણન કરતા એક સામાન્ય અંગ્રેજી વાક્યની અંદર છુપાયેલા હોય છે.
Theory
તમારા business ના nouns અને verbs
Meera ની દુકાનને એક વાક્યમાં વર્ણવો: "એક customer એક order આપે છે items માટે." વ્યાકરણે હમણાં તમને design આપી દીધું. Nouns (customer, order, item) એ entities છે, એ વસ્તુઓ જેને તમે store કરો છો. જે વિગતો તમે ઉમેરશો ('customer નું name, item ની price') એ attributes છે. Verb ('આપે છે') એ relationship છે. E/R design મોટા ભાગે એક સાદા વર્ણનમાંથી nouns અને verbs વાંચવું છે.
At a glance
ત્રણ E/R building blocks
| Element | છે | આકાર / બને છે |
|---|---|---|
| Entity | એક વસ્તુ જેને તમે store કરો છો (Customer) | Rectangle / એક table |
| Attribute | એક વિગત (name, price) | Ellipse / એક column |
| Relationship | એક association (BUYS) | Diamond / એક link |
Theory
ત્રણેય, બરાબર
- Entity: એક વાસ્તવિક-દુનિયાની વસ્તુ જેના વિશે તમે data રાખો છો, Customer, Item, Order. એક rectangle તરીકે દોરેલી. દરેક entity એક table બને છે.
- Attribute: એક entity નો ગુણ, એક Customer નું name અને phone, એક Item ની price. એક ellipse તરીકે દોરેલો. દરેક attribute એક column બને છે.
- Relationship: entities ના વચ્ચે એક association, સામાન્ય રીતે એક verb: Customer ખરીદે છે Item, Customer આપે છે Order. એક diamond તરીકે દોરેલી.
ધ્યાન આપો: entity to table, attribute to column એ બરાબર Meera ની spreadsheet છે (items rows માં નીચે, વિગતો columns માં આરપાર), હવે એક ઠીકઠાક design શબ્દાવલી સાથે.
Quiz
'એક customer એક order આપે છે' માં, કયો શબ્દ RELATIONSHIP છે?
- આપે છે (બંને entities ને જોડતો verb)
- customer
- order
- એક
Show the answer
આપે છે (બંને entities ને જોડતો verb)
આપે છે એ બંને entities (Customer અને Order) ને જોડતો verb છે, તો એ relationship છે, એક diamond તરીકે દોરેલી. 'Customer' અને 'order' એ entities છે (nouns, rectangles તરીકે દોરેલી). noun-સામે-verb heuristic, nouns entities/attributes બને છે, verbs relationships બને છે, એ એક વર્ણનમાંથી એક E/R design વાંચવાની સૌથી ઝડપી રીત છે.
Think first
Entity કે attribute?
Meera ની દુકાનમાં, શું 'phone number' એક ENTITY છે કે એક ATTRIBUTE? અને 'Supplier' નું શું? એ test જણાવો જે તમે નક્કી કરવા વાપર્યો.
Show the answer
'Phone number' એ attribute છે (એક customer ની વિગત, એક ellipse તરીકે દોરેલી, એક column બને છે). 'Supplier' એ entity છે (પોતાની ખુદની વિગતો જેમ કે name અને address વાળી એક વસ્તુ, એક rectangle તરીકે દોરેલી, એક table બને છે). Test: શું એ પોતાના ખુદના ગુણો સાથે એકલી ઊભી રહી શકે? જો હા, entity; જો એ બસ કોઈ બીજી વસ્તુનું વર્ણન કરતી વિગત છે, attribute. આ entity-સામે-attribute પરખ એ E/R design નું મૂળ કૌશલ્ય છે.
Watch out
Marks ક્યાં કપાય છે
આકાર ભેળવવા: entity = rectangle, attribute = ellipse, relationship = diamond, exams સાચા symbols ના marks આપે છે. એક entity (એક એકલી વસ્તુ, એક table બને છે) ને એક attribute (એક વિગત, એક column બને છે) સાથે ભેળવવી. અને એ ભૂલવું કે relationships સામાન્ય રીતે verbs છે. જ્યારે એક paragraph માંથી 'entities, attributes અને relationships ઓળખો' કહેવાય, પહેલા nouns અને verbs ને underline કરો, એ ભરોસાપાત્ર રીત છે.
Theory
આ blueprint વાળો તબક્કો છે
દરેક સાચો database project અહીંથી શરૂ થાય છે: client સાથે વાત કરો, business ને વાક્યોમાં લખો, entities, attributes અને relationships કાઢો, E/R diagram દોરો, પછી tables બનાવો. એને છોડો અને તમને Meera ની ગૂંચવાયેલી spreadsheet મળે છે. તમારા BCA project માં, એક E/R diagram ઘણી વાર એક જરૂરી deliverable હોય છે. આગળનો lesson relationships માં મહત્વની વિગત ઉમેરે છે: કેટલા, one-to-one, one-to-many, many-to-many (cardinality).
Summary
Key takeaways
- E/R model એક database ને બનાવતાં પહેલાં ત્રણ blocks થી design કરે છે.
- Entity: એક વસ્તુ જેને તમે store કરો છો (Customer, Item), એક rectangle તરીકે દોરેલી, એક table બને છે.
- Attribute: એક entity ની વિગત (name, price), એક ellipse તરીકે દોરેલી, એક column બને છે.
- Relationship: entities ના વચ્ચે એક association (BUYS, આપે છે), એક diamond તરીકે દોરેલી, સામાન્ય રીતે એક verb.
- Heuristic: nouns entities/attributes બને છે, verbs relationships બને છે.
- યાદ રાખવાની યુક્તિ: તમારા business ના nouns અને verbs મોટેથી વાંચો.