Jump to content

Database

From Simple English Wikipedia, the free encyclopedia
Revision as of 04:12, 25 March 2023 by Vadder (talk | changes) (greatly simplify the example of a database system and definition of terms)

A database is a computer system for storing and taking care of data (any kind of information).

When the software that runs a database is separate from the programs that use the database, it is called a database engine.

Information stored inside a database is usually stored in an organized way. Data about a person that would have been written on a piece of paper before databases would be stored in a record in a database. A collection of person records that would have been an address book before databases would be stored in a file or table.

Uses for database systems

Uses for database systems include:

  • They store data and provide facilities (tools) to search for specific records in a given set of data.
  • They store special information used to manage the data. This information is called metadata and it is not shown to all the people looking at the data.
  • They can solve cases where many users want to access (and possibly change) the same entries of data.
  • They manage access rights (who is allowed to see the data, who can change it)
  • When there are many users asking questions to the database, the questions must be answered faster. In this way, the last person to ask a question can get an answer in a reasonable time.
  • Certain attributes are more important than others and can be used to find other data. This is called indexing. An index contains all the important data and can be used to find other data.
  • They ensure that the data always has context. There are a lot of different rules that can be added to tell the database system if the data makes sense. One of the rules might say November has 30 days. This means if someone wants to enter November 31 as a date, this change will be rejected.

Changing data

In databases, some data changes occasionally. There may be problems when data is changed; for example, an error might have occurred. The error might make the data useless. The database system looks at the data to ensure that it meets certain requirements. It does this by using a transaction. There are two points in time in the database, the time before the data was changed, and the time after the data was changed. If something goes wrong when changing the data, the database system simply puts the database back into the state before the change happened. This is called a rollback. After all the changes are done successfully, they are committed. This means that the data makes sense again; committed changes can no longer be undone.

In order to be able to do this, databases follow the ACID principle:[1]

  • All. Either all tasks of a given set (called a transaction) are done, or none of them is. This is known as Atomicity.
  • Complete. The data in the database always makes sense. There is no half-done (invalid) data. This is known as Consistency.
  • Independent. If many people work on the same data, they will not see (or impact) each other. Each of them has their own view of the database, which is independent of the others. This is known as Isolation.
  • Done. Transactions must be committed, when they are done. Once the committed, they can not be undone. This is known as Durability.

Database model

There are different ways how to represent the data.

  • Simple files (called flat files): This is the most simple form of database system. All the data is stored in a simple file.
  • Hierarchical model: The data is organized like a tree. Every piece of data relates to another piece of data that is closer to the root of the tree.
  • Network model: This is similar to the hierarchical model, but has much more complex structure. Every piece of data relates to another piece of data, but there is no single root that everything relates to.
  • Relational model: This is the most widely-used kind of database in business. Data is organized in tables. The tables can be joined together as needed for queries. This model uses set theory and predicate logic.
  • Object oriented model: The data is represented in the form of objects. Software created using object-oriented programming can work easily with the data.
  • Object relational model: This uses parts of both the relational model and the object oriented model.
  • NoSQL model:[2] This is a new kind of database model and is increasing being used in the industry in big data and real-time web applications.[3] The data in this model is stored as key-value pairs without any strict hierarchy as in other models. NoSQL systems are also referred to as "Not only SQL" because they are often used without using SQL, but sometimes they can be used with SQL.[4]

Ways to organize the data

Data can be looked at from different perspectives, and it can be organized in different ways.

Database Normalisation was developed to organize data. Currently there are six Normal forms. These are ways to make some databases faster and make the data take less space.

An example of database normalization is storing a person's address in one place, and linking that address to all the other records about that person. When the address is updated in the one place it is stored, all the other records will be linked to the new address automatically.

References

  1. "What are the ACID properties? | Data Basecamp". 2022-07-02. Retrieved 2022-07-07.
  2. "What are NoSQL Databases? | Data Basecamp". 2021-12-10. Retrieved 2022-07-01.
  3. "RDBMS dominate the database market, but NoSQL systems are catching up". DB-Engines.com. 21 Nov 2013. Retrieved 24 Nov 2013.
  4. "Structured Query Language (SQL) | Data Basecamp". 2021-12-26. Retrieved 2022-07-01.