In database, an attribute represents a property of interest of an entity.
Attributes are described in the database structure using a data model.
For example, you could have an entity called «Student». This entity can be made up of one or more attributes, which are properties of the «Student» entity that are of interest to be stored in the database.
The «Student» entity could have the attributes: first name, last name, year of birth, etc.
The choice of the attributes of an entity depends on the use that will be given to the database. The student can have a «religion», but if it does not matter at the end of the database, it is not necessary to store it in an attribute.
Attributes in SQL
In SQL, attributes are represented in columns, like entities in tables.
In order to obtain the attributes of a table in SQL, SQL queries are used.
Concrete example of attributes in a diagram
The PERSON entity has the attributes ID, which is a number that identifies it and is a key, and the attributes name and surname.
Entity CITY has a Code (postal) attribute that uniquely identifies it and a city name.
There is also the relationship that unites both entities. In this case a person was born in a single city, but a single city can have multiple people born in it (this is cardinality).
So to implement this diagram in SQL two tables will be created, Person table and Entity table.
For the relationship between these, it will not be necessary to create a table because it is a (1,n) relationship, that is, a person has a single city of birth, while a city has multiple people born.
In this case the Person table will have the attributes: id, name, surname, code (from the city)
Meanwhile, the City table will have its original attributes: code, name
related terminology
SQL query
Doubts? needs more information? Write and we will respond to your email: click here