Introduction to SQLSQL DatabaseSQL DatatypesSQL QueriesSQL DML StatementsSQL Constraints and IndexingSQL FunctionsStored Procedure and Triggers
Database architecture refers to the design of the database system, how data is stored, how relationships are defined, and how data is accessed.
Tables, Rows, and Columns
1. Tables
- A table is a collection of data organized into rows and columns.
- Each table represents an entity, such as employees, orders, or products.
- Tables are defined by a schema that specifies their columns (attributes) and the data types of those columns.
Example: A table called employees
might have columns such as employee_id
, first_name
, last_name
, hire_date
, salary
.
2. Rows (Records)
- A row in a table represents a single record or instance of the entity.
- For example, in the
employees
table, each row would represent an individual employee, with specific values for each column.
Example:
employee_id | first_name | last_name | hire_date | salary |
---|---|---|---|---|
1 | John | Doe | 2020-01-01 | 50000 |
2 | Jane | Smith | 2019-02-01 | 55000 |
3. Columns (Attributes)
- Columns define the types of data that each record can store, such as
name
,address
,phone_number
, etc. - Each column has a name and a data type (e.g.,
VARCHAR
for text,INT
for integers,DATE
for dates).
Example (for employees
table):
employee_id
(INT)first_name
(VARCHAR)last_name
(VARCHAR)hire_date
(DATE)salary
(DECIMAL)