Attributes and Tables

Attributes and Tables

Understanding Attributes

  • Attributes are the characteristics or properties that represents the objects within a system in a database.
  • These can take the form of several data types, including text strings, integers, decimal numbers, dates, and Booleans.
  • Each attribute in a database must have a unique name.
  • Attributes can allow or disallow null values.
  • These properties describe the features of the data that is being stored.
  • An attribute’s data type dictates what kind of data can be stored in that attribute.

Primary Keys

  • A Primary Key is a specific form of attribute that uniquely identifies every record in a database table.
  • Primary keys must contain unique values, and cannot contain null values.
  • A table can have only one primary key.

Understanding Tables

  • In the context of databases, a table is a set of data elements organised using a model of vertical columns (which are identified by their name) and horizontal rows.
  • The cell is the intersection of the row and column.
  • A table has a specified number of columns, but can have any number of rows.
  • The term relation is used to refer to a table, as a table is fundamentally a mathematical relation.

Table Relationships

  • Table relationships define how data in one table relates to data in another table.
  • Table relationships can be one-to-one, one-to-many, or many-to-many.

Foreign Keys

  • A foreign key is a column or group of columns in a relational database table that provides a link between data in two tables.
  • It acts as a cross-reference between tables because the foreign key in one table is a primary key in another table.

Database Normalisation

  • Database normalisation is the process of structuring a relational database in accordance with a series of normal forms in order to reduce data redundancy and improve data integrity.
  • Normalisation involves decomposing a table into less redundant and smaller tables without losing information.
  • Defining foreign keys in the old table referencing the primary keys of the new ones.
  • The objective is to isolate data so that additions, deletions, and modifications of a field can be made in just one table and then propagated through the rest of the database via the defined foreign keys.