Basic concepts of databases

AB – Andmebaas
DB – Database
БД – База данных

DBMS – Database Management System

program examples:

MS Acess
Oracle
MS SQL

Database tasks:

Database storage

Receiving data on request

Data integrity

60s – the beginning of the emergence of databases

Data types:

numeric:

int, smallint, tinyint
decimal(4,1) – number with 1 after coma, 4 – total

text and characters:

varchar(10) – 10 -max chars
char(11)
TEXT – free space, how much you like

logic:

boolean, bool, bit, true/false

date/time:

date
time
datetime
interval

Record, field, table

lines = record
columns = fields
entity – olem

SQL – Structured Query Language
Query – запрос, päring
DDL – Data definition language – Дата для создания таблиц и опрд.
create table, drop table, alter table
DML – Data manipulation language – Работает с записями в таблице
select, insert, update, delete, merge

XAMPP control panel

Apache –Start
MySQL–Start

CREATE TABLE opilane( tabeli loomine
    opilaneID int PRIMARY KEY AUTO_INCREMENT,
    eesnimi varchar(20) not null,
    perenimi varchar(30) not null,
    isikukood char(11),
    synniaeg date)
INSERT INTO opilane(eesnimi, perenimi, synniaeg, isikukood)
VALUES ('Mark','Markin','2000-12-22','44544545544')

Select * from opilaneID – выбрать * (все) из (списка, название)

UPDATE opilane SET synnikoht='Tallinn'
WHERE opilaneID=1; 
SELECT * FROM opilane; 

adding a column (name) to the list edit (by value, number) select (from, * -example) (table name)

ALTER TABLE opilane ADD COLUMN synnikoht varchar(20)
UPDATE opilane SET keskmineHine=4.4
WHERE opilaneID=3; 
SELECT * FROM opilane; 

Primary KEY – PK – attribute / or a set of them, which is uniquely defined. string, there are no two identical key values, AUTO_INCREMENT – auto. filling the key field with increasing values of 1, etc.

Foreign KEY – FK – secondary key is a relationship between tables. The secondary key contains a link to the AK of another table

CREATE TABLE hindamine(
    hindamineID int primary key AUTO_INCREMENT,
    opilaneID int,
    foreign key (opilaneID) references opilane(opilaneID),
    oppeaine varchar(12),
    hinne int);

creating and binding to another value per key

To display a table

ALTER TABLE opilane ADD ryhmID int
UPDATE opilane SET ryhmID= (значение)
ALTER TABLE opilane ADD constraint fk_ryhm2 foreign key (ryhmID) REFERENCES ryhm(ryhmID)