What is a table, row, column, field in SQL database
October 13, 2020
In the previous post we discussed the basic terms related to relational (SQL) databases – what is a relational (SQL) database, why data should be stored in multiple tables. What issues we face if store data in one SQL table instead of multiples. Have a look at the previous post, if some of the concepts mentioned above are not familiar to you.
So the SQL table is used to store data and display / retrieve data from once user or application sends a corresponding request. The table consists of rows and fields.
Let’s consider the above. As you can see, it consists of 4 rows or records. A record is a table’s entity, which consists of fields. A record contains data about one table object. In this example we have 3 objects (persons), so each row represents one person. Based on a record (row), we can find the basic data about a person, that is, name, last name, date of birth. Row term in SQL table context is equivalent to record term.
A field is a part of a record with independent meaning. When we define a field, we should follow the rule – field should contain one piece of data, which cannot be further divided. In the above example, each record consists of 4 fields – person ID, name, last name and date of birth. And it would be incorrect to create a field, which would contain both name and last name. This would make harder to work with data, for example, to filter or sort data based on name or last name only. SQL has capabilities to merge multiple fields in the one on the fly if / when needed.
Each field has a field name, which helps users to identify the content of a given field. And database management system uses this name to identify a field and what data should be loaded into it. Fields, which has the same name, form a column. In our example there are 4 columns.
Field can hold only data of the particular type. Data type determines what kind of data could be inserted and stored in this particular field. The most common data types are text, number related data types, date.
In the next post we will continue discussing basics and will talk about primary keys and indexes. Stay turned