DATA with BARAA

SQL Table​s

SQL Tables

In this tutorial, we will learn about the concept and components of SQL tables. Understanding SQL tables can help us retrieve information more efficiently. 

Here is a simple example of a SQL table named Customers from our tutorial database that is used to process customer orders:

Database Terminology

As you may have noticed, database terminology uses different terms, e.g. row, record and tuple are all synonymous. 

The reason for this is that there are currently almost 380 databases that use different terms in their documentation. Another reason is that different terms are used depending on the work area, for example:

  • As a data modeler, the most common terms are Entity and Attribute.
  • As a database developer, you may use terms like Table, Column, Row.
  • In studies and literature, the terms Relation, Tuple, and Attribute are often used.

 

Let’s understand this in detail:

.

Tables

Tables are the place where data are stored in the database and the most simple form of data storage. It is the most important object and without it, we have no database.

A table is a collection of data elements organized in terms of rows and columns. 

In our tutorial database, the table Customers contains all data of all customers.

Other used terms for Table are Object, Entity, and Relation

Columns

A column is a vertical group of cells that describe one type of information. The above Customers table consists of four columns and each has two information:  

Each column has two information:

  • Column name – in our example the column names are customer_id, first_name, last_name, and country. On an important note, a table can’t contain columns with the same names and a column name can’t be empty.
  • Column values – each column contains values such as all first names: Mary, John, George, Martin, and Peter. The values could be empty, depending on the restriction you make in the table.

Other used terms for Columns are Attribute, and Field

Rows

A row is a horizontal group of cells that contains all data of an individual topic. A row in a table represents a set of related data. For example, the above Customers table has 5 rows/customers.

In our example, the horizontal highlighted row contains all the information about the customer John. His customer ID is 2, his last name is Steel, and his country is the USA.

Other used terms for Rows are Record and Tuple

Cells

A cell is one value, a single item of data, and one piece of information where a row and a column intersects. In our example, data like John is a cell

Other used terms for Cells are Data Item and Column Value

Primary Key

A Primary Key is a column that can uniquely identify each row in a table and might be used as a link within other tables.

In our example the column customer_id has unique value to identify each customers.

Another used term for Primary Key is Key Field. 

.
Share it !
Exit mobile version