A Database Attribute Defines the Properties of a Table

Think of an attribute as a characteristic

Cropped Image Business People Discussing Over Laptop At Desk In Meeting

Sarinya Pinngam / EyeEm/Getty Images 

A database is more powerful than the spreadsheet it resembles because it has an enormous search capability. Relational databases cross-reference entries in different tables and perform complex calculations on large amounts of interconnected data. The information is organized in a way that is easily managed, accessed, and updated.

What Is an Attribute?

A database consists of tables. Each table has columns and rows. Each row (called a tuple) is a data set that applies to a single item. Each column (attribute) contains describing characteristics of the rows. A database attribute is a column name and the content of the fields under it in a table in a database.

If you sell products and enter them into a table with columns for ProductName, Price, and ProductID, each of those headings is an attribute. In each field under those headings, you'll enter the product names, prices, and product IDs, respectively. Each one of the field entries is also an attribute.

An attribute is a single piece of data in the tuple to which it belongs. Each tuple is a data set that applies to one item.

This makes sense when you think of it, given that the nontechnical definition of an attribute is that it defines a characteristic or quality of something. 

Attributes Describe Entities

Consider a database developed by a business. It likely includes tables — also called entities by database designers — for Customers, Employees, and Products, among others. The Products table defines the characteristics of each product. These might include a product ID, a product name, a supplier ID (used as a foreign key), a quantity, and a price. Each of these characteristics is an attribute of the table (or entity) named Products.

Consider this snippet from the often-cited Northwinds database:

screenshot of an Attribute chart

The column names are the attributes of a product. The entries in the fields of the columns are also attributes of a product.

Is an Attribute a Field?

Sometimes, the term field and attribute are used interchangeably, and for most purposes, they are the same thing. However, field describes a particular cell in a table found on any row, while attribute describes an entity characteristic in a design sense.

In the table above, the ProductName in the second row is Chang. This is a field. If you are discussing products in general, ProductName is the product's column. This is the attribute.

Defining Attributes

Attributes are defined in terms of their domain. A domain defines the allowable values that an attribute can contain. This includes its data type, length, values, and other details.

For example, the domain for an attribute ProductID might specify a numeric data type. The attribute can be further defined to require a specific length or specify whether an empty or unknown value is allowed.