TIL - (11/8) Databases

Hailey Park·2021년 11월 13일
0

TIL

목록 보기
1/8
post-thumbnail

What is database?

A database generally refers to a structured collection of structured information or data stored electronically in a computer system. The database is usually controlled by a database management system (DBMS). Data and DBMS are referred to as 'database systems' along with related applications, and are also collectively referred to as 'databases' for short. (Oracle)

The reason for using a database is not to volatile data, but to store it for a long period of time and at the same time to keep it organized.

RDBMS (Relational DataBase Management System) 관계형 데이터베이스

There are two main types of databases: relational databases (RDBMS) and non-relational databases called "NoSQL".

In a relational database, all data can be represented as a two-dimensional table.

  • column : A column represents each item in the table.
  • row : A row is the actual value of each item.

Each row has its own primary key.

The first column in a table is always id . When you think of Excel or a spreadsheet, do you remember that the first column is always numbered (index) that does not change? Each row always has a unique number. This is called the Primary Key.
You can find or reference a specific row through this primary key.

The types of relations

There are three types of ralations between tables.

  • One to One : A relationship between a row in table A and a row in table B is exactly one-to-one. One A data is associated with one B data. One B data is also associated with one A data.

  • One to Many : A relationship in which a row in table A is connected to several rows in table B is called a one to many relationship. One row in A table is associated with multiple rows in B table. One row in B table is associated with one row in A table.

  • Many to Many : A relationship in which multiple rows in table A are linked to multiple rows in table B. Let's look at the relationship between a book and the author who wrote it. One author can write multiple books and a book can have multiple authors. In this way, when two tables are connected with multiple data from different tables, a junction table is created to input the combination of data belonging to the two tables.

  • We mainly use the concept of foreign key to connect.
  • If an id value that is not in the users table is specified for user_id, an error occurs.

If you put all the information in one table, the same information is redundantly stored unnecessarily. This will use more disks and increase the chances of erroneous data being stored. The two problems disappear if you divide the data into several tables and then link the necessary tables. This is called database normalization.

profile
I'm a deeply superficial person.

3개의 댓글

comment-user-thumbnail
2023년 4월 6일

who need help improving their coding skills butterfly locs, daily game solve cross

답글 달기
comment-user-thumbnail
2023년 4월 30일

StuartSkrabanek credible login

답글 달기
comment-user-thumbnail
2023년 8월 10일

StefaniMastenbrook https://ultraspicyhouse.com

답글 달기