Академический Документы
Профессиональный Документы
Культура Документы
MYSQL
HAROLD R. LUCERO,MIT
MYSQL
DEFINITION OF TERMS
MYSQL
DEFINITION OF TERMS
MYSQL
DEFINITION OF TERMS
MYSQL
DEFINITION OF TERMS
MYSQL
DEFINITION OF TERMS
Data Type: data types are the
properties of each field. A field
only has one data type, such as
Character, Number or Date.
MYSQL
DATABASE COMPONENTS
Table: Tables are where the actual data is defined and
entered.
Queries: Queries are basically questions about the data in a
database. Queries allow you to extract data based on the
criteria you define.
Forms: Forms are designed to ease the data entry process.
For example, you can create a data entry form that looks
exactly like a paper form .
Reports: when you want to print records from your
database, design a report.
DATABASE MANAGEMENT SYSTEM
MYSQL
MYSQL
NAMING CONVENTIONS
Avoid Quotes
Lowercase
Data types are not names
Underscores separate words
Full words, not abbreviations
Use common abbreviations
Avoid reserved words
MYSQL
SINGULAR RELATIONS
Tables, views, and other relations that hold data
should have singular names, not plural. This means
our tables and views would be named team, not teams.
MYSQL
MYSQL
DATATYPES IN MYSQL
Numeric Data Types
MYSQL
DATATYPES IN MYSQL
Numeric Data Types
MYSQL
DATATYPES IN MYSQL
String Data Types
CHAR(M) - A fixed-length string between 1 and
255 characters in length (for example CHAR(5)),
right-padded with spaces to the specified length
when stored. Defining a length is not required, but
the default is 1.
VARCHAR(M) - A variable-length string between 1
and 255 characters in length; for example
VARCHAR(25). You must define a length when
creating a VARCHAR field.
DATABASE MANAGEMENT SYSTEM
MYSQL
DATATYPES IN MYSQL
String Data Types
BLOB or TEXT - A field with a maximum length of
65535 characters. BLOBs are "Binary Large
Objects" and are used to store large amounts of
binary data, such as images or other types of files.
Fields defined as TEXT also hold large amounts of
data; the difference between the two is that sorts
and comparisons on stored data are case sensitive
on BLOBs and are not case sensitive in TEXT fields.
You do not specify a length with BLOB or TEXT.
DATABASE MANAGEMENT SYSTEM
MYSQL
DATATYPES IN MYSQL
String Data Types
TINYBLOB or TINYTEXT - A BLOB or TEXT
column with a maximum length of 255 characters.
You do not specify a length with TINYBLOB or
TINYTEXT.
MEDIUMBLOB or MEDIUMTEXT - A BLOB or
TEXT column with a maximum length of 16777215
characters. You do not specify a length with
MEDIUMBLOB or MEDIUMTEXT.
MYSQL
DATATYPES IN MYSQL
String Data Types
LONGBLOB or LONGTEXT - A BLOB or TEXT
column with a maximum length of 4294967295
characters. You do not specify a length with
LONGBLOB or LONGTEXT
ENUM - An enumeration, which is a fancy term for
list. When defining an ENUM, you are creating a list
of items from which the value must be selected (or it
can be NULL).
MYSQL
DATATYPES IN MYSQL
Date and Time Data Types
MYSQL
FIELD PROPERTIES
LEN Specifies the length
DEFAULT This property allows you to set the default
value for the field.
PRIMARY KEY - The PRIMARY KEY constraint uniquely
identifies each record in a database table.
NOT NULL - The NOT NULL constraint enforces a
column to NOT accept NULL values.
MYSQL
FIELD PROPERTIES
UNSIGNED - Make any numeric type UNSIGNED if it
won't ever store negative numbers
ZEROFILL - the field numeric values will be positive or 0
and leading zeros will be added to a number
AUTO_INCREMENT - description is also added to the
column, which tells MySQL to use the next-highest
number as the user_id value for each added record
MYSQL
MANAGING A DATABASE
Login in MySQL Database
MYSQL
MANAGING A DATABASE
Creating a Database
Before doing anything else with the data, you need to
create a database. A database is a container of data. It
stores contacts, vendors, customers or any kind of data
that you can think of. In MySQL, a database is a
collection of objects that are used to store and
manipulate data such as tables, database views,
triggers, stored procedures, etc.
MYSQL
MANAGING A DATABASE
Displaying Databases
The SHOW DATABASES statement displays all
databases in the MySQL database server. You can use
the SHOW DATABASES statement to check the database
that youve created or to see all the databases on the
database server before you create a new database, for
example:
MYSQL
MANAGING A DATABASE
Selecting a database to work with
Before working with a particular database, you
must tell MySQL which database you want to work with by
using the USE statement.
MYSQL
MANAGING A DATABASE
Removing Databases
Removing database means you delete the
database physically. All the data and associated objects
inside the database are permanently deleted and this
cannot be undone. Therefore, it is very important to
execute this query with extra cautions.
MYSQL
MYSQL
MANAGING A DATABASE
Creating Tables
In order to create a new table within a database,
you use the MySQL CREATE TABLE statement. The
CREATE TABLE statement is one of the most complex
statement in MySQL
MYSQL
MANAGING A DATABASE
Creating Tables
To define a column for the table in the CREATE
TABLE statement, you use the following syntax:
MYSQL
MANAGING A DATABASE
Creating Tables
Ex.
MYSQL
ACTIVITY 1
1. Create a database in localhost and use your LastName as your database
name
2. Set your database as the active database and create the table below using
member as the table name.
FIELDS
memberid
first_name
middle_name
last-named
birthday
DATATYPE