Derek Banas - Data Types Intro Flashcards
Numeric Data Types
- TINYINT
- SMALLINT
- MEDIUMINT
- INT
- BIGIN
- BOOL
- FLOAT
- DECIMAL
Date and Time Data Types
- DATE
- DATETIME
- TIMESTAMP
- TIME
- YEAR
String Data Types
- VARCHAR
- BLOB
- MEDIUMBLOB
- LONGBLOB
- ENUM
- SET
Limits of TINYINT
From: -127
To: 127
Storage: 1 byte
Limits of SMALLINT
From: -2^15 (-32,768)
To: 2^15 - 1 (32,767)
Storage: 2 bytes
Limits of MEDIUMINT
From: -2^23 (-8,388,608)
To: 2^23 - 1 (8,388,607)
Storage: 3 bytes
Limits of INT
From: -2^31 (-2,147,483,648)
To: 2^31 - 1 (2,147,483,647)
Storage: 4 bytes
Limits of BIGINT
From: -2^63 (-9,223,372,036,854,775,808)
To: 2^63 - 1 (9,223,372,036,854,775,807)
Storage: 8 bytes
Limits of BOOL
0 OR 1
Definition of FLOAT(size, d)
A floating point number (has a decimal point). The total number of digits is specified in size. The number of digits after the decimal point is specified in the d parameter.
Definition of DECIMAL(size, d)
An exact fixed-point number. The total number of digits is specified in size. The number of digits after the decimal point is specified in the d parameter. The maximum number for size is 65. The maximum number for d is 30. The default value for size is 10. The default value for d is 0.
Limit of TIME
Max 838:59:59.000000
Limit of YEAR
1901 - 2155
Definition of BLOB
For BLOBs (Binary Large OBjects). Holds up to 65,535 bytes of data.
Blobs are typically images, audio or other multimedia objects, though sometimes binary executable code is stored as a blob. Database support for blobs is not universal.
Definition of ENUM
A string object that can have only one value, chosen from a list of possible values. You can list up to 65535 values in an ENUM list. If a value is inserted that is not in the list, a blank value will be inserted. The values are sorted in the order you enter them
Definition of SET
A string object that can have 0 or more values, chosen from a list of possible values. You can list up to 64 values in a SET list
Data Constraints
- NOT NULL
- DEFAULT
- UNSIGNED
- PRIMARY KEY
- AUTO_INCREMENT
Definition of NOT NULL
Must have a value, can’t have a value of NULL
Definition of DEFAULT
Designate a value when ever a row is created without data
Definition of UNSIGNED
Can’t use negative values
Defitintion of PRIMARY KEY
Identified as unique values assigned to a raw
Definition of AUTO_INCREMENT
Each time a row of data is created you would mark anything that is set to auto increment to NULL, and the database would automatically increemnt that value. Can only use auto increment to one column per table– column must be primary or unique key.
1 table should represent 1…
real world object
Columns store
1 piece of information
Normalizing databases means:
reducing redundant data
Primary keys are……………, while foreign keys are………………….. .
Primary keys are unique identifiers, while foreign keys are primary keys in another talbe.
Conditional Operator: Not Equal to
<>
OR
!=