Database Architecture (1-tier, 2-tier, 3-tier): comparison, advantages, disadvantages

Database architecture એ વિશે છે કે user ને data થી કેટલા સ્તર અલગ કરે છે: 1-tier બધું એક machine પર છે, 2-tier માં client સીધા server સાથે વાત કરે છે, અને 3-tier એક વચ્ચેનો application server ઉમેરે છે જેને મોટા ભાગની આધુનિક web apps વાપરે છે.

10 min read · 9 cards · 2 checks

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


Theory

એક counter, કે આખી કંપની?

Meera નો data એના business ના વધતાં ત્રણ અલગ દુનિયામાં રહે છે:

1. ફક્ત એ, એક PC પર, Excel વાપરતી.

2. counter computer પર એક billing app જે પાછળના ઓરડાના database સાથે વાત કરે છે.

3. એક online store જ્યાં customers ના browsers એક website દ્વારા એના data સુધી પહોંચે છે.

દરેક user અને data ના વચ્ચે એક સ્તર ઉમેરે છે. એ સ્તર-ગણતરી, 1-tier, 2-tier, 3-tier, database architecture છે, અને સાચો પસંદ કરવો એ એક સાચો design નિર્ણય છે (અને એક પ્રમાણભૂત exam સરખામણી).

Theory

પાણી મેળવવું: કૂવો, નળ, શહેરી પુરવઠો

1-tier: પોતાના આંગણમાં એક કૂવો, તમે જાતે પાણી ખેંચો છો, બીજું કોઈ સામેલ નહીં. 2-tier: સીધા ટાંકી સાથે જોડાયેલો એક નળ, તમે ખોલો છો અને પાણી આવે છે, એક સીધો link. 3-tier: શહેરી જળ પ્રણાલી, તમારો નળ એક treatment plant સાથે જોડાય છે જે જળાશય સાથે જોડાય છે, વચ્ચે સ્તરો જે આખા શહેર માટે filter, control અને scale કરે છે. વધુ tiers, વધુ અલગાવ, વધુ control.

At a glance

ત્રણ tiers

ArchitectureStructureસામાન્ય ઉપયોગ
1-tierUser, app, data એક જ machine પરExcel, એકલો desktop tool
2-tierClient app સીધા DB server સાથે વાત કરે છેનાની office નું billing app
3-tierClient > app server > DB serverWeb અને mobile apps

Theory

3-tier એ web કેમ જીત્યું

3-tier માં, client (browser) ક્યારેય database ને સીધું અડતું નથી. એ એક વચ્ચેના application server સાથે વાત કરે છે જે business logic રાખે છે અને DB સાથે વાત કરે છે. એ વચ્ચેનું સ્તર ત્રણ વસ્તુઓ આપે છે:

  • Security: database credentials server પર રહે છે, ક્યારેય client માં નહીં.
  • Scalability: હજારો clients app server પર આવે છે, જે DB સાથે connections pool કરે છે.
  • Maintainability: logic ને એક જગ્યાએ (વચ્ચે) બદલો દરેક client update કર્યા વગર.

બરાબર એટલે જ લગભગ દરેક website, Gri-Learn સહિત, 3-tier છે.

Quiz

એક 3-tier architecture માં, શું client (browser) database સાથે સીધું વાત કરે છે?

  1. ના, એ એક વચ્ચેના application server સાથે વાત કરે છે, જે database સાથે વાત કરે છે
  2. હા, client સીધું database ને SQL મોકલે છે
  3. હા, પણ ફક્ત વાંચવા માટે, લખવા માટે નહીં
  4. 3-tier માં કોઈ client નથી હોતું
Show the answer

ના, એ એક વચ્ચેના application server સાથે વાત કરે છે, જે database સાથે વાત કરે છે

3-tier ની વ્યાખ્યાયિત વિશેષતા વચ્ચેનો application/logic server છે: client એની સાથે વાત કરે છે, અને ફક્ત એ જ database સાથે વાત કરે છે. Client ક્યારેય DB ને સીધું જોતું નથી, એ જ 3-tier ને એની security (credentials છુપા) અને scalability આપે છે. એક client સીધું DB ને SQL મોકલતું એ 2-tier (client-server) નું વર્ણન છે, બરાબર એ contrast જે exams test કરે છે.

Think first

Meera નું online store passwords લીક કરે છે?

ધારો કે Meera એ પોતાનું online store 2-tier તરીકે બનાવ્યું: customer નું browser સીધું એના database સાથે વાત કરે છે. ઝડપની આગળ, આ કઈ ગંભીર સમસ્યા ઊભી કરે છે, અને 3-tier એને કેવી રીતે ઠીક કરે છે?

Show the answer

Browser ને database ના login credentials જોઈએ, જેનો અર્થ છે દરેક customer નું device ખરેખર એના આખા database ની ચાવીઓ રાખે છે, એક વિનાશક security છિદ્ર (કોઈ પણ બધો data વાંચી કે બરબાદ કરી શકે). 3-tier એને ઠીક કરે છે: credentials ફક્ત વચ્ચેના application server પર રહે છે; browser બસ server ને નમ્રતાથી પૂછે છે અને ક્યારેય database કે એનો password જોતું નથી. Data ને એક logic સ્તર ની પાછળ છુપાવવો એ એક મુખ્ય security કારણ છે કે 3-tier web પર હાવી છે.

Watch out

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

Tiers ખોટા ગણવા: 1-tier = એક machine, 2-tier = client સીધું DB server સાથે વાત કરતું, 3-tier = એમની વચ્ચે એક સ્તર. એમ કહેવું કે 3-tier નું client DB સાથે વાત કરે છે, એ નથી કરતું, એ 2-tier છે. અને advantages/disadvantages સવાલોમાં, એમને જોડીમાં કરો: 1-tier (સરળ પણ share ન થાય), 2-tier (સીધું/ઝડપી પણ ભારે client, નબળું scaling/security), 3-tier (સલામત/scalable પણ વધુ જટિલ). સંતુલિત pros-and-cons પૂરા marks અપાવે છે.

Theory

તમે 3-tier માં જીવો છો

અત્યારે: તમારું browser (tier 1, presentation) Gri-Learn ના server (tier 2, logic) સાથે વાત કરે છે જે એક database (tier 3, data) સાથે વાત કરે છે. આ app ની જ રચના એ exam જવાબ છે. જ્યારે તમે તમારો BCA project એક web app તરીકે બનાવશો, તમે એને પણ 3-tier બનાવશો, આ theory નથી, આ તમારા ભવિષ્યના કામનો આકાર છે. આગળ: database MODELS, data ને જાતે ગોઠવવાની અલગ રીતો.

Summary

Key takeaways

  • Architecture user અને data ના વચ્ચેના સ્તર ગણે છે.
  • 1-tier: user, app અને data એક machine પર (Excel, એક local tool). સરળ, share ન થાય.
  • 2-tier: એક client app સીધું એક database server સાથે વાત કરે છે (client-server). ઝડપી પણ ભારે client, નબળું scaling/security.
  • 3-tier: client > વચ્ચેનો application server > database server. Client ક્યારેય DB ને અડતું નથી.
  • 3-tier નું વચ્ચેનું સ્તર security (છુપા credentials), scalability અને maintainability આપે છે, web પ્રમાણ.
  • યાદ રાખવાની યુક્તિ: કૂવો (1) સામે નળ-થી-ટાંકી (2) સામે શહેરી જળ પ્રણાલી (3).

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

Database Architecture (1-tier, 2-tier, 3-tier): comparison, advantages, disadvantages · Data Processing and Analysis (DPA) · Gri-Learn