A database is a collection of related data that can be stored, sorted, organized, and queried. Data in a database is organized into fields, records, and tables. In this article, we will explain what these terms mean and how they are used in a database.
Fields
A field is a category of information in a database. For example, in a student information database, a field could be name, date of birth, student ID number, etc. A field can have different types of data, such as text, numbers, dates, or objects. A field can also have certain properties, such as default value, validation rule, or primary key.
Records
A record is a collection of related fields in a database. A record represents a single entity or instance of data. For example, in a student information database, a record could contain the name, date of birth, student ID number, and other fields for one student. A record can also be called a row or a tuple.
Tables
A table is a group of related records in a database. A table represents a set of data about a specific topic or subject. For example, in a school database, there could be tables for students, courses, teachers, etc. A table can also be called a file or a relation.
Relationships
In a relational database, which is the most common type of electronic database, tables can be linked or related to each other based on common fields. For example, in a school database, there could be a relationship between the students table and the courses table based on the student ID field. This allows the database to retrieve data from multiple tables using queries.
A relationship can be one-to-one, one-to-many, or many-to-many depending on how many records in one table correspond to records in another table. For example, in a school database, there could be a one-to-one relationship between the students table and the teachers table based on the advisor field (each student has one advisor and each teacher advises one student), a one-to-many relationship between the teachers table and the courses table based on the instructor field (each teacher teaches one or more courses and each course has one instructor), and a many-to-many relationship between the students table and the courses table based on the enrollment field (each student enrolls in one or more courses and each course has one or more students).
To maintain data integrity and consistency in a relational database, there are rules and constraints that govern the relationships between tables. One of these rules is referential integrity, which means that for each value in the foreign key of one table (a field that references another table), there is a corresponding value in the primary key of another table (a field that uniquely identifies each record).