Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between attribute and a column created with ALTER?

Tags:

sql

mysql

oracle

I am new to SQL. I am confused between 'attribute' and a custom column we create with 'ALTER' . For Example:

ALTER TABLE table_name
ADD column_name datatype

Doesn't this 'column_name' be our new attribute in the table ?

like image 655
Abhilash Murali Avatar asked Feb 01 '15 18:02

Abhilash Murali


People also ask

What is difference between attribute and column?

A "Column" is a column in a database table whereas "attribute(s)" are externally visible facets of an object. An "attribute" is for a model and a "column" is for a table in a database. Here "retreats" is a table in a database with the following columns "title", "tagline", "created_at", "updated_at".

Is attribute the same as a column in SQL?

You can think of an attribute as a column in an entity table. An attribute value is the value used to describe a specific member.

What is the relationship between attributes and columns?

The columns in a table is a field and is also referred to as an attribute. You can also think of it this way: an attribute is used to define the record and a record contains a set of attributes.

Does attribute mean column?

An attribute is simply one non-null cell in the spreadsheet, or the conjunction of a column and row. It stores only one piece of data about the object represented by the table in which the attribute belongs.


2 Answers

The confusion is due to a difference in the terminology we use for the logical "model" and the database implementation.

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

When we implement the model into a relational database, an "attribute" for an "entity" gets stored as a "column" in a "table".

In the (implemented) relational database, a "table" contains "columns".

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

(This relates to the standard relational model, and disregards any discussion of implementing an Entity-Attribute-Value (EAV) model in the database.)


For example:

ALTER TABLE order
  ADD COLUMN date_received DATETIME ;  

This is adding a column, with a column name of date_received to the order table.

We add the column, because in the logical model, the "Order" entity has an attribute of "date received".

like image 92
spencer7593 Avatar answered Oct 17 '22 16:10

spencer7593


The Entity-Relationship design discipline covers "entities" that have "attributes." The physical-level RDBMS design discipline covers "table" and "columns." An entity -- a person -- might have an attribute of "given name". The corresponding table would be called person in an RDBMS, and it would have a column called given_name.

Entities and columns are the same thing in slightly different kinds of jargon.

like image 27
O. Jones Avatar answered Oct 17 '22 18:10

O. Jones