Quiz 2

19 - Application Design & Development

486 words
2 min read
Python Week 1: the first filter for runtime behavior
Visual companion
Python
Type and operator map

Python Week 1: the first filter for runtime behavior

View
Revision summary

What this note is really saying

Short form

# 19 - Application Design & Development ## 🎯 Learning Objectives After reading this topic, you will be able to: - Describe the 3-tier architecture (presentation, business logic, data) - Explain how applications connect to databases (ODBC, JDBC, Python DB-API) - Understand cookies and sessions for state management -...

19 - Application Design & Development

🎯 Learning Objectives

After reading this topic, you will be able to:
  • Describe the 3-tier architecture (presentation, business logic, data)
  • Explain how applications connect to databases (ODBC, JDBC, Python DB-API)
  • Understand cookies and sessions for state management
  • List RAD frameworks and their advantages

📖 Core Content

19.1 3-Tier Architecture

(Diagram)
TierRoleTechnologies
PresentationUser interface, displayHTML, CSS, JavaScript, React
Business LogicApplication logic, validationPython (Flask/Django), Java, Node.js
Data AccessData storage and retrievalPostgreSQL, MySQL, Oracle
Advantages:
  • Modularity: Each tier can be developed independently
  • Scalability: Scale each tier separately
  • Security: Data tier is never exposed to clients

19.2 Database Connectivity

ODBC (Open Database Connectivity)

  • Standard API for accessing databases from C/C++
  • Database-independent: same code works for different DBMS
  • Uses a driver manager to translate calls

JDBC (Java Database Connectivity)

  • Java equivalent of ODBC
  • Four types of drivers (Type 1-4), with Type 4 (pure Java) being most common

Python DB-API

Standard interface for Python database access:
python
import psycopg2  # PostgreSQL adapter
conn = psycopg2.connect(
    host="localhost",
    database="university",
    user="postgres",
    password="secret"
)
cur = conn.cursor()
cur.execute("SELECT name, salary FROM instructor WHERE dept_name = %s", ('CS',))
results = cur.fetchall()
for row in results:
    print(f"Name: {row[0]}, Salary: {row[1]}")
cur.close()
conn.close()
Other Python drivers: pg8000, ocpgdp, PyGreSQL

19.3 Cookies and Sessions

ConceptLocationPurpose
CookieClient-side (browser)Stores small data (session ID, preferences)
SessionServer-sideStores user state during interaction
How it works:
  1. User logs in → Server creates a session, sends a session cookie
  2. Browser sends cookie with each request → Server looks up session
  3. User logs out → Session destroyed, cookie expires

19.4 WSGI (Web Server Gateway Interface)

Python standard for connecting web servers (Apache, Nginx) to Python applications (Flask, Django).

19.5 RAD Frameworks

FrameworkLanguageFeatures
Ruby on RailsRubyConvention over configuration, scaffolding
DjangoPythonAdmin interface, ORM, batteries-included
FlaskPythonLightweight, extensible
Spring BootJavaEnterprise-grade, dependency injection
ASP.NETC#Microsoft ecosystem, MVC pattern

19.6 Embedded SQL

SQL statements embedded directly in host language code:
c
EXEC SQL SELECT name, salary
    INTO :name_var, :sal_var
    FROM instructor
    WHERE ID = :id_var;
Pre-processed by the SQL pre-processor before compilation.

📝 Practice Questions

Q1. Describe the 3-tier architecture and its advantages.

Answer
Tiers: Presentation (UI), Business Logic (application server), Data Access (database server)
Advantages: Modularity, independent scalability, security (data never exposed to clients), reusability of components.

Q2. What is the difference between cookies and sessions?

Answer
Cookies are stored client-side; sessions are stored server-side. Sessions are more secure (data not exposed to the client). Cookies are typically used to store the session ID.

Q3. List two Python drivers for PostgreSQL.

Answer
psycopg2, pg8000, ocpgdp, PyGreSQL (any two).

🔗 Cross-References

Document outline

Keep your place and jump directly to a heading.

Table of Contents
System Normal // Awaiting Context

Intelligence Hub

Navigate the knowledge graph to generate context. The Hub adapts dynamically to surface backlinks, related notes, and metadata insights.