Difference between attribute and column created with ALTER?

I am new to SQL. I am confused between the "attribute" and the custom column that we create with "ALTER". For instance:

ALTER TABLE table_name ADD column_name datatype 

Isn't 'column_name' our new attribute in the table?

+5
source share
2 answers

The confusion is due to the difference in terminology that we use for the logical “model” and implementation of the database.

In an (logical) Entity Relationship Model (ERM), an Entity has Attributes.

When we embed a model in a relational database, the “attribute” for the “entity” is stored as a “column” in the “table”.

In a (implemented) relational database, a “table” contains “columns”.

We add attributes to entities; we add columns to tables.

(This refers to the standard relational model and ignores any discussion of the implementation of the Entity-Attribute-Value (EAV) model in the database.)


For instance:

 ALTER TABLE order ADD COLUMN date_received DATETIME ; 

This adds the column with the column name date_received to the order table.

We add a column because in the logical model the Order object has the attribute "received date".

+7
source

The discipline of Entity-Relationship design encompasses "entities" that have "attributes." The discipline of RDBMS design at the physical level covers the “table” and “columns”. An entity - a person - may have the attribute "given name". The corresponding table will be called person in RDBMS, and it will have a column named given_name .

Entities and columns are the same thing in several different jargons.

+2
source

Source: https://habr.com/ru/post/1212386/


All Articles