数据库的特性

Persistence (allowing access later, after it was created)
Shared source of truth accessible by many users
Ability to store many types of data (efficiently)
Concurrency control (handling multiple db actions at once)


Relational Databases

  • All data is stored in tables
  • Every table is characterized by a list of columns with data types per column, and its set of data (organized in rows)
  • Comes with rules for enforcing data integrity such as constraints and triggers.

Primary Key

  • The primary key is the unique identifier for the entire row, referring to one or more columns.
  • If there are more multiple columns for the primary key, then the set of primary key columns is known as a composite key.

Foreign Key

  • A primary key in another (foreign) table.
  • Foreign keys are used to map relationships between tables.

A SELECT statement is used to query the database for slices of data.

SQL (Structured Query Language)

  • The standard language for communicating with a relational database.
  • Every relational database system has its own “flavor” of SQL it implements because they are not 100% compliant with the SQL standard.
  • Each flavor is called a dialect that is unique per database management system.

Inner joins between two tables returns rows of data that exist across all joined tables, excluding rows that may only exist in one of the tables but not the other table.

Outer joins return every row that exists in the left (in a left outer join) or right (in a right outer join) joined table, while rendering NULL values on rows whose foreign key does not match a record in the other (right or left) table.


Relational database systems follow a client-server model:
Servers, Clients, Hosts

  • In a Client-Server Model, a server serves many clients
  • Servers and clients are programs that run on hosts
  • Hosts are computers connected over a network (like the internet!)

Requests and Responses

  • A client sends a request to the server
  • The server’s job is to fulfill the request with a response it sends back to the client.
  • Requests and responses are served via a communication protocol, which sets up the expectations and rules for how the communication occurs between servers and clients.

Relational Database Clients

  • A database client is any program that sends requests to a database
  • In some cases, the database client is a web server! When your browser makes a request, the web server acts as a server (fulfilling that request), but when the web server requests data from the database, it is acting as a client to that database - and the database is the server (because it is fulfilling the request).

Basically, we call things clients when they are making a request and servers when they are fulfilling a request. Since a web server can do both, it sometimes acts as a server and sometimes acts as a client.


The web server receives a request from the client and sends a request to the database, which sends back a response to the web server, which then sends back a response to the client.


你可能感兴趣的:(数据库,数据库,database)