Creating Databases  «Prev  Next»

Lesson 4Integrating a database with a Web site
Objective Describe the technologies used to connect databases to the Web.

Integrating Database with Website

In a client-server architecture for connecting a database to a website, several key technologies and components are typically involved. The architecture generally includes a web server, a database server, and the necessary software stack to facilitate communication between these components. Here's an overview of the technologies used:
  1. Web Server: This is the core component that delivers web pages to the client's browser. Popular web servers include Apache, Nginx, and Microsoft's Internet Information Services (IIS). The web server handles HTTP requests from clients and serves the appropriate content.
  2. Database Server: The database server stores and manages data. Common database management systems (DBMS) used in web applications are MySQL, PostgreSQL, Microsoft SQL Server, and Oracle. The choice of DBMS often depends on the requirements of the application, such as data complexity, scalability needs, and transaction support.
  3. Server-Side Scripting Language: A server-side scripting language is used to create dynamic web pages that interact with the database. Languages like PHP, Python (with frameworks like Django or Flask), Ruby (Ruby on Rails), and JavaScript (Node.js) are commonly used. These languages have libraries and frameworks that facilitate database connectivity and operations.
  4. Database Connectivity Libraries/APIs: To connect the web server with the database server, specific libraries or APIs are used. For instance, PHP uses PDO (PHP Data Objects) or mysqli (MySQL Improved) for connecting to MySQL databases. Python has libraries like SQLAlchemy or Django ORM for database interactions.
  5. HTML/CSS/JavaScript: On the client side, HTML, CSS, and JavaScript are used to build the user interface of the web application. JavaScript can also be used to make asynchronous requests to the server (using AJAX) for a smoother user experience without reloading the entire page.
  6. RESTful APIs or GraphQL: For modern web applications, RESTful APIs or GraphQL are often used to facilitate communication between the client (such as a web browser or mobile app) and the server. These APIs define a set of rules and methods to retrieve and manipulate data over HTTP.
  7. JSON/XML: These are common data formats used for exchanging data between the server and the client. JSON (JavaScript Object Notation) and XML (eXtensible Markup Language) are widely used due to their simplicity and interoperability across different platforms and languages.
  8. SSL/TLS Encryption: Secure Socket Layer (SSL) or Transport Layer Security (TLS) encryption is vital for securing data transmission between the client and the server, especially when sensitive information like personal data or payment details are involved.
  9. Web Application Frameworks: Frameworks like Laravel (PHP), Express (Node.js), ASP.NET (C#), and Spring (Java) provide structured ways to build web applications, including database connectivity, routing, and session management.

Each of these technologies plays a specific role in the ecosystem of a web application. The choice of technologies can vary based on the specific needs of the application, such as performance requirements, scalability, security, and the development team's expertise.
To integrate a database with a Web site, you need a mechanism that lets the Web server and the database server communicate.
On the Web server side, this mechanism is in the form of CGI scripts[1], APIs, and custom middleware[2] solutions. These mechanisms are used to talk to the database server. On the database server, database access protocols are used to access the data in a database. You will learn more about the communication process in the following Slide Show.


Communication Process

1) The client sends a request to the Web Server
1) The client sends a request to the Web Server

2) The web server sends this request to the database server
2) The web server sends this request to the database server

3) The database server queries the database and gets the information
3) The database server queries the database and gets the information

4) The database server returns this information to the web server
4) The database server returns this information to the web server

5) The web server sends information to the client
5) The web server sends information to the client


Common Database Access Protocols

There are some database access protocols that you should be familiar with. The most common is called ODBC (or Open Database Connectivity). Another protocol is JDBC (or Java Database Connectivity). JDBC was developed by Sun Microsystems. OLE-DB is a Microsoft technology that is limited to the Windows NT platform. It provides limited support for databases, but is supported by the most popular databases. It is also possible to write code that directly interfaces with the database. This is referred to as native support. Native support is a way to enhance performance, but the downside is that it provides less portability. In the next lesson, you will learn more about using ODBC and SQL to connect a database to the Web.

Database Integration - Quiz

Click the Quiz link below to test your understanding of the database information you've learned so far.
Database Integration - Quiz

[1]CGI: Common Gateway Interface (CGI) is a specification for writing programs that enables transactions between a Web server and other programs on a server.
[2] Middleware: Software that functions as a translator to enable one application to communicate with another that either runs on a different platform or comes from a different vendor.

Ad SQL and Relational Theory