Time information from January 1, 1970 to January 18, 2038, in the format Year+Month+Day+Hour+Minute+Second.
YYYYMMDDHHMMSS
CE208-Database Management Systems
MYSQL Data Types
DATE:
Date field that can change from 1000-01-01 to 9999-12-31.
YYYY-MM-DD
CE208-Database Management Systems
MYSQL Data Types
CHAR(n):
Fixed-length data with n characters.
CE208-Database Management Systems
MYSQL Data Types
TEXT:
A text field that can hold up to 65535 characters.
CE208-Database Management Systems
MYSQL Data Types
MEDIUMTEXT:
Text field up to 16777215 characters
CE208-Database Management Systems
MYSQL Data Types
VARCHAR(n):
Characters of varying size, not exceeding n
CE208-Database Management Systems
MYSQL Data Types
BOOL:
A data type that takes the value 0 or 1. or True/ False
CE208-Database Management Systems
Key
A key forces one or more fields to be entered as qualifiers for a row.
There are 2 types of keys:
Primary Key
Foreign Key
CE208-Database Management Systems
Primary key
It is the key data that will enable access to a record.
For example, there are two Ahmet among the students. Each student must have a unique number in order to find the Ahmet we want while searching.
For example student number could be a primary key
Multiple fields can have primary keys together
CE208-Database Management Systems
Foreign key
A foreign key is a set of attributes in a table that refers to the primary key of another table. The foreign key links these two tables.
CE208-Database Management Systems
Foreign key
Persons Table
PersonID
LastName
FirstName
Age
1
Hansen
Ola
30
2
Svendson
Tove
23
3
Pettersen
Kari
20
CE208-Database Management Systems
Foreign key
Orders Table
OrderID
OrderNumber
PersonID
1
77895
3
2
44678
3
3
22456
2
4
24562
1
CE208-Database Management Systems
Foreign key
Notice that the "PersonID" column in the "Orders" table points to the "PersonID" column in the "Persons" table.
The "PersonID" column in the "Persons" table is the PRIMARY KEY in the "Persons" table.
The "PersonID" column in the "Orders" table is a FOREIGN KEY in the "Orders" table.
The FOREIGN KEY constraint prevents invalid data from being inserted into the foreign key column, because it has to be one of he values contained in the parent table.