slide môn học MySQL bài 2 using MySQL

38 6 0
  • Loading ...
1/38 trang

Thông tin tài liệu

Ngày đăng: 30/11/2016, 22:10

Using MySQL Session Review - I      Binary distribution contains setup program that installs every component for the server to start Source distribution contains all the codes and support files for making the files executable MySQL is compatible with Solaris, Linux, Windows 9x/NT/2000/XP, Mac OS X, FressBSD, and AIX operating systems Configure script enables user to control the MySQL distribution To configure MySQL use various options of configure on the command line MySQL Database / Session / Slide of 38 Review - II    MySQL is configured using the combination of commandline options, configuration files, and environment variables Programs like mysql, mysqladmin, mysqld, mysqld_safe, mysql.server, mysqldump, mysqlimport, mysqlshow, mysqlcheck, myisamchk, and myisampack supports option files of my.cnf file To initiate MySQL at the startup, configure the operating system to place MySQL server at the startup MySQL Database / Session / Slide of 38 Objectives     List Naming Conventions used in MySQL Create a Database and Tables Use Data Types Implement the concept of Referential integrity and indexing MySQL Database / Session / Slide of 38 Naming Conventions in MySQL    We can use the following for database and table names:  Alphabets a-z or A-Z  Digits (0-9)  Characters such as ‘_ ‘ or ‘$’ We cannot use the following for the database and table name:  Character ‘.’  Separator characters such as ‘/’ or’\’ A name may start with a digit but it cannot contain of entire digits MySQL Database / Session / Slide of 38 Case Sensitivity in MySQL- I     The SQL statements and keywords are not case sensitive The case sensitivity of the database and table names depends on the type of the operating system being used On a windows operating system the database name and the table name are not case sensitive On a UNIX operating system the database and table names are case sensitive MySQL Database / Session / Slide of 38 Case Sensitivity in MySQL - II   The column and the index name are not case sensitive We use one of the following SQL statements to display the column ‘FNAME’ from a SAMPLE table: SELECT FNAME from SAMPLE ( ); SELECT fname from SAMPLE ( ); MySQL Database / Session / Slide of 38 Creating Database -I  Databases are used to store information A database consists of several tables  The syntax for creating a database is: CREATE DATABASE [IF NOT EXISTS] MySQL Database / Session / Slide of 38 Creating Database-II  To create a EMPLOYEE database,enter the following at the command prompt: CREATE DATABASE EMPLOYEE; MySQL Database / Session / Slide of 38 Data Types Classification  Data types are classified into:  Numeric  String  Date  Complex MySQL Database / Session / Slide 10 of 38 Creating Tables-I   MySQL creates an ‘.frm’ file to hold the table and column definitions If we not specify the table type the default table type is MyISAM Types of tables:  Transaction-safe  Non-transaction MySQL Database / Session / Slide 24 of 38 Features of transaction tables      Provides safety from data loss Enables user to combine many statements and execute all the commands by issuing the COMMIT command Enables the user to ignore changes by issuing ROLLBACK command Provides better concurrency if many users are simultaneously reading data from the table Examples of transaction-safe tables are InnoDB and BDB MySQL Database / Session / Slide 25 of 38 Features of non-transaction safe tables     Faster than the transaction-safe tables as no transaction overhead is required Lesser disk space is required Lesser memory required for updates Example of non-transaction safe are HEAP, ISAM, MERGE, and MyISAM MySQL Database / Session / Slide 26 of 38 Creating Table-III  The syntax for creating a table is: CREATE [TEMPORARY] TABLE [IF NOT EXISTS]table create_clause, ) table_options] [IGNORE [REPLACE] select] MySQL Database / Session / Slide 27 of 38 Creating Table -IV  To create a EMP_DETAILS table, enter the following at the command prompt: CREATE TABLE EMP_DETAILS(E_ID INT(3),E_FNAME CHAR(10), E_LNAME CHAR(15), E_ADDRESS CHAR(15),E_PHONE_NO INT(6)); MySQL Database / Session / Slide 28 of 38 Viewing the Table Structure   The syntax to view the structure is: DESCRIBE table [column] To view the structure of the table created, enter the following at the command prompt: DESC EMP_DETAILS; MySQL Database / Session / Slide 29 of 38 Normalization - I    Data is structured in a table to minimize duplication and inconsistency in data Involves breaking down of a table into two or tables and defining relationships between them Improves the clarity in the database MySQL Database / Session / Slide 30 of 38 Normalization - II     Entity - Represents an object about which we want to store the information Attributes - Represents the component of entity type Domain -Defines the range for the attributes Relationship - Represents association between entities MySQL Database / Session / Slide 31 of 38 Defining Keys   Keys are used to describe the relation between columns These keys uniquely identify a record Types of keys:  Primary key: is a column in the table which is used as the unique identifier  Composite key: is a primary key having more than one attribute  Foreign key: is a key in table which is also the Primary Key in another table MySQL Database / Session / Slide 32 of 38 Forms of Normalization - I    Different forms of normalization are applied on a database A database is in the first normal form if:  All attributes are atomic  All columns have only one instance A database is in 2NF if:  It is in the first normal form  All non key attributes entirely depend on the unique identifier of the entity MySQL Database / Session / Slide 33 of 38 Forms of Normalization - II   A database is in 3NF if:  It is in the second form  No attribute is dependent on non-key attribute A database in the Boyce-Codd normal if:  It is in the third normal form  Only one unique identifier exists MySQL Database / Session / Slide 34 of 38 Database Concepts-I       Referential integrity feature prevents users or applications from entering inconsistent data To implement referential integrity, foreign key must exits Indexing is used on databases to make the find and search operations faster Indexes can be defined while creating the table A field on which the search is to be performed is indexed Several fields in a table can also be indexed at a time Indexing reduces the speed of updating a database MySQL Database / Session / Slide 35 of 38 Summary - I        Databases are used to store information Relational Databases consists of several tables A table consists of rows and columns Data types are classified as numeric, String, Date and Complex Numeric data types are used to store numerical data String data types holds data that consists of characters from a-z and numbers from 0-9 Date data type column have date values entered as string values in the form of 'YYYY-MM-DD' format MySQL Database / Session / Slide 36 of 38 Summary - II     Normalization is the process in which the redundancies in the database are removed A Primary key is a field in the table which is used as the unique identifier An entity is said to be in the first normal form if all the attributes are single valued An entity is said to be in the second normal form, if it is in the first normal and all non key attributes entirely depend on the unique identifier of the entity MySQL Database / Session / Slide 37 of 38 Summary - III    An entity is said to be in the Boyce-Codd normal form if it is already in the third normal form and only one unique identifier exists Referential integrity deals with consistency of data of related tables Indexing a database facilitates a faster find and sort operations in the database MySQL Database / Session / Slide 38 of 38 [...]... for unsigned and from 9 ,22 3,3 72, 036,854,775,808 to 9 ,22 3,3 72, 036,854,775,807 for signed number  Storage: 8 MySQL Database / Session 4 / Slide 11 of 38 Numeric Data Types - II  DOUBLE: Stores double precision floating point numbers  Range: Between 1.7976931348 623 157E+308 and -2. 225 07385850 720 14E-308,0 for a negative number and between 2. 225 07385850 720 14E-308 and 1.7976931348 623 157E+308 for a positive... 16,777 ,21 5 for a unsigned number  Storage: 3 MySQL Database / Session 4 / Slide 13 of 38 Numeric Data Types - IV   SMALLINT (length): Stores integer numbers  Range: From - 32, 768 to 32, 767 for a signed number and 0 to 65,535 for an unsigned number  Storage :2 TINYINT: Stores integer numbers  Range: From - 128 to 127 for a signed number and from 0 to 25 5 for an unsigned number  Storage: 1 MySQL Database... number  Storage: 8  DECIMAL (length, decimal): Stores floating numbers  Storage: Precision +2  Synonyms: DEC, NUMERIC MySQL Database / Session 4 / Slide 12 of 38 Numeric Data Types - III   INT: Stores integer numbers  Range: Between 2, 147,483,648 to 2, 147,483,647for a signed number and between 0 to 4 ,29 4,967 ,29 5 for a unsigned number  Storage:4  Synonyms: INTEGER MEDIUMINT (length): Stores integer... 1900 to 21 55  Storage: 1 MySQL Database / Session 4 / Slide 20 of 38 Date Data Types - IV  TIMESTAMP- Stores the timestamp  Format: YYYY-MM-DDhhmmss  Storage: 4 MySQL Database / Session 4 / Slide 21 of 38 Complex Data Types-I    Complex data type is a special string data type Enables the user to list the possible values to be inserted in a column The complex data types are:   ENUM SET MySQL. .. Database / Session 4 / Slide 22 of 38 Complex Data Types-II   SET- Stores a list of values from a predefined set of values Maximum of 64 values are stored in a SET data type column  Storage: 1-8 ENUM- Stores one value out of a possible 65535 number of options in a predefined list of possible values  Storage: 1 ,2 MySQL Database / Session 4 / Slide 23 of 38 Creating Tables-I   MySQL creates an ‘.frm’... default date format is: 'YYYY-MM-DD' MySQL Database / Session 4 / Slide 18 of 38 Date Data Type – II   DATE- Stores a date type of data  Format: YYYY-MM-DD  Storage: 3  Range: January 1,1000 to December 31,9999 DATETIME: Stores date and time  Format: YYYY-MM-DD hh:mm:ss  Storage: 8  Range: 1000-01-01 00:00:00 to 9999- 12- 31 23 :59:59 MySQL Database / Session 4 / Slide 19 of 38 Date Data Type - III... transaction-safe tables are InnoDB and BDB MySQL Database / Session 4 / Slide 25 of 38 Features of non-transaction safe tables     Faster than the transaction-safe tables as no transaction overhead is required Lesser disk space is required Lesser memory required for updates Example of non-transaction safe are HEAP, ISAM, MERGE, and MyISAM MySQL Database / Session 4 / Slide 26 of 38 Creating Table-III  The... create_clause, ) table_options] [IGNORE [REPLACE] select] MySQL Database / Session 4 / Slide 27 of 38 Creating Table -IV  To create a EMP_DETAILS table, enter the following at the command prompt: CREATE TABLE EMP_DETAILS(E_ID INT(3),E_FNAME CHAR(10), E_LNAME CHAR(15), E_ADDRESS CHAR(15),E_PHONE_NO INT(6)); MySQL Database / Session 4 / Slide 28 of 38 Viewing the Table Structure   The syntax to view... MEDIUMTEXT: Stores medium-sized text whose size up to 16MB  Storage: Length+3 MySQL Database / Session 4 / Slide 16 of 38 String Data Types- III   LONGTEXT: Stores large text values whose exceeds 4GB  Storage: Length+4 TEXT: Stores medium-sized text whose size up to 64KB  Storage: Length +2 MySQL Database / Session 4 / Slide 17 of 38 Date Data Type-I    A date data type is used to store of various... following at the command prompt: DESC EMP_DETAILS; MySQL Database / Session 4 / Slide 29 of 38 Normalization - I    Data is structured in a table to minimize duplication and inconsistency in data Involves breaking down of a table into two or tables and defining relationships between them Improves the clarity in the database MySQL Database / Session 4 / Slide 30 of 38 Normalization - II     Entity
- Xem thêm -

Xem thêm: slide môn học MySQL bài 2 using MySQL , slide môn học MySQL bài 2 using MySQL , slide môn học MySQL bài 2 using MySQL

Gợi ý tài liệu liên quan cho bạn

Nạp tiền Tải lên
Đăng ký
Đăng nhập