A relational database at its simplest is a set of tables used for storing data. Each table has a unique name and may relate to one or more other tables in the database through common values.
A table in a database is a collection of rows and columns. Tables are also known as entities or relations.
A row contains data pertaining to a single item or record in a table. Rows are also known as records or tuples.
A column contains data representing a specific characteristic of the records in the table. Columns are also known as fields or attributes.
A relationship is a link between two tables (i.e, relations). Relationships make it possible to find data in one table that pertains to a specific record in another table.
Each of a table’s columns has a defined datatype that specifies the type of data that can exist in that column. For example, the FirstName column might be defined as varchar(20), indicating that it can contain a string of up to 20 characters. Unfortunately, datatypes vary widely between databases.
Most tables have a column or group of columns that can be used to identify records. For example, an Employeestable might have a column called EmployeeID that is unique for every row. This makes it easy to keep track of a record over time and to associate a record with records in other tables.
Foreign key columns are columns that link to primary key columns in other tables, thereby creating a relationship. For example, the Customers table might have a foreign key column called SalesRep that links to EmployeeID, the primary key in the Employees table.
The UPDATE is a SQL command used to edit/update existing records in a database table.
Relational Database Management System
A Relational Database Management System (RDBMS), commonly (but incorrectly) called a database, is software for creating, manipulating, and administering a database. For simplicity, we will often refer to RDBMSs as databases.
PostgreSQL is an object-oriented open source relational database management system, which uses a subset of SQL language.
Normalization is the process of organizing data to minimize redundancy and remove ambiguity. Normalization involves separating a database into tables and defining relationships between the tables. There are three main stages of normalization called normal forms. Each one of those stages increases the level of normalization. The 3 main normal forms are as follows:
- First Normal Form (1NF): Each field in a table must contain different information.
- Second Normal Form (2NF): All attributes that are not dependent upon the primary key in a database table must be eliminated.
- Third Normal Form (3NF): No duplicate information is permitted. So, for example, if two tables both require a common field, this common field information should be separated into a different table.
There are 2 more normalization forms, fourth normal form (4NF) and fifth normal form (5NF), but they are rarely used. Normalization makes databases more efficient and easier to maintain.
A NULL value in a table is a value in a field that appears to be blank which means A field with a NULL value is a field with no value.
It is very important to understand that a NULL value is different than a zero value or a field that contains spaces. A field with a NULL value is one that has been left blank during record creation
The following categories of the data integrity exist with each RDBMS:
- Entity Integrity : There are no duplicate rows in a table.
- Domain Integrity : Enforces valid entries for a given column by restricting the type, the format, or the range of values.
- Referential integrity : Rows cannot be deleted, which are used by other records.
- User-Defined Integrity : Enforces some specific business rules that do not fall into entity, domain, or referential integrity.