This document discusses database views in MySQL. It defines a view as a virtual table composed of the result set of a SELECT query. Views allow users to retrieve and update data as if it were a table. The document outlines how to create views from SELECT statements, how to make views updatable by following certain rules, and how to manage views using SHOW, ALTER, and DROP commands.
This document discusses database replication in MySQL. It begins by explaining the concepts and principles of replication, including that it allows for maintaining synchronized copies of databases across multiple servers. It then covers how to set up replication between a master and slave server by enabling binary logging on the master, creating a backup, configuring the servers, restoring the backup on the slave, and starting the replication process. Finally, it discusses how to verify replication is working properly and manage the replication process ongoing.
This document discusses various topics relating to query optimization in database management systems, including:
- Optimizing SQL statements and database structure to improve query performance
- Understanding query execution plans and how they are generated by the optimizer
- Using the EXPLAIN statement to analyze queries and identify optimizations
- Common join types like nested loops, indexes that can improve joins, and optimizing column data types for joins
- Estimating query performance based on factors like disk seeks and index usage
- Measuring actual performance with tools like BENCHMARK()
- Internal optimizations in MySQL like those for NULL values and different join types
The document provides examples of using EXPLAIN to optimize a join query involving multiple tables, and
This document discusses database transactions in three parts:
1) It introduces transaction types including explicit, implicit, and auto-commit transactions.
2) It explains the ACID properties that transactions must satisfy - Atomicity, Consistency, Isolation, and Durability.
3) It provides examples of using transactions in MySQL, including starting a transaction, rolling back or committing changes, and setting the isolation level.
The document discusses optimizing database performance in MySQL. It covers optimizing at the database level through proper database structure and indexing. Some key points include structuring tables efficiently with the right data types, columns, and row formats. Indexes should support common queries. The document also discusses optimizing queries through indexing columns used in WHERE clauses and using LIMIT to improve performance. Hardware optimizations involve issues like disk seeks, reads/writes, CPU usage, and memory bandwidth.
This document discusses database indexing and how indexes are used in MySQL. It begins with an introduction to indexing and describes several types of indexes, including single-level ordered indexes, multilevel indexes, and dynamic multilevel indexes using B-trees and B+-trees. It then provides examples of how to create and use indexes on tables in MySQL, including creating indexes on single or multiple columns and viewing existing indexes. The document aims to explain how database indexes improve query performance in MySQL.
This document discusses database transactions in three parts:
1) It introduces transaction types including explicit, implicit, and auto-commit transactions.
2) It explains the ACID properties that transactions must satisfy - Atomicity, Consistency, Isolation, and Durability.
3) It provides examples of using transactions in MySQL, including starting a transaction, rolling back or committing changes, and setting the isolation level.
The document discusses how to use the mysqldump utility in MySQL to back up and restore databases. It explains how to back up individual tables or entire databases using mysqldump and various options. It also discusses how to restore databases from backup files by running the SQL statements in the backup file. The document emphasizes that binary log files should also be used to update the restored database to the most recent state after the backup was performed. It provides examples of restoring data directly from binary log files or exporting the binary log data to a text file first before restoring.
The document discusses enhanced entity-relationship (EER) modeling concepts, including subclasses and superclasses, specialization and generalization, categories, and attribute inheritance. It provides examples of each concept and constraints on specialization and generalization. Key points include:
- Subclasses represent subgroups of a superclass and inherit attributes and relationships.
- Specialization defines subclasses based on distinguishing characteristics, while generalization identifies a superclass from common subclass features.
- Categories represent subclasses that can exist in multiple superclasses through a union.
- Constraints include disjointness, completeness, and whether subclasses are predicate-defined or user-defined.
This document discusses database views in MySQL. It defines a view as a virtual table composed of the result set of a SELECT query. Views allow users to retrieve and update data as if it were a table. The document outlines how to create views from SELECT statements, how to make views updatable by following certain rules, and how to manage views using SHOW, ALTER, and DROP commands.
This document discusses database replication in MySQL. It begins by explaining the concepts and principles of replication, including that it allows for maintaining synchronized copies of databases across multiple servers. It then covers how to set up replication between a master and slave server by enabling binary logging on the master, creating a backup, configuring the servers, restoring the backup on the slave, and starting the replication process. Finally, it discusses how to verify replication is working properly and manage the replication process ongoing.
This document discusses various topics relating to query optimization in database management systems, including:
- Optimizing SQL statements and database structure to improve query performance
- Understanding query execution plans and how they are generated by the optimizer
- Using the EXPLAIN statement to analyze queries and identify optimizations
- Common join types like nested loops, indexes that can improve joins, and optimizing column data types for joins
- Estimating query performance based on factors like disk seeks and index usage
- Measuring actual performance with tools like BENCHMARK()
- Internal optimizations in MySQL like those for NULL values and different join types
The document provides examples of using EXPLAIN to optimize a join query involving multiple tables, and
This document discusses database transactions in three parts:
1) It introduces transaction types including explicit, implicit, and auto-commit transactions.
2) It explains the ACID properties that transactions must satisfy - Atomicity, Consistency, Isolation, and Durability.
3) It provides examples of using transactions in MySQL, including starting a transaction, rolling back or committing changes, and setting the isolation level.
The document discusses optimizing database performance in MySQL. It covers optimizing at the database level through proper database structure and indexing. Some key points include structuring tables efficiently with the right data types, columns, and row formats. Indexes should support common queries. The document also discusses optimizing queries through indexing columns used in WHERE clauses and using LIMIT to improve performance. Hardware optimizations involve issues like disk seeks, reads/writes, CPU usage, and memory bandwidth.
This document discusses database indexing and how indexes are used in MySQL. It begins with an introduction to indexing and describes several types of indexes, including single-level ordered indexes, multilevel indexes, and dynamic multilevel indexes using B-trees and B+-trees. It then provides examples of how to create and use indexes on tables in MySQL, including creating indexes on single or multiple columns and viewing existing indexes. The document aims to explain how database indexes improve query performance in MySQL.
This document discusses database transactions in three parts:
1) It introduces transaction types including explicit, implicit, and auto-commit transactions.
2) It explains the ACID properties that transactions must satisfy - Atomicity, Consistency, Isolation, and Durability.
3) It provides examples of using transactions in MySQL, including starting a transaction, rolling back or committing changes, and setting the isolation level.
The document discusses how to use the mysqldump utility in MySQL to back up and restore databases. It explains how to back up individual tables or entire databases using mysqldump and various options. It also discusses how to restore databases from backup files by running the SQL statements in the backup file. The document emphasizes that binary log files should also be used to update the restored database to the most recent state after the backup was performed. It provides examples of restoring data directly from binary log files or exporting the binary log data to a text file first before restoring.
The document discusses enhanced entity-relationship (EER) modeling concepts, including subclasses and superclasses, specialization and generalization, categories, and attribute inheritance. It provides examples of each concept and constraints on specialization and generalization. Key points include:
- Subclasses represent subgroups of a superclass and inherit attributes and relationships.
- Specialization defines subclasses based on distinguishing characteristics, while generalization identifies a superclass from common subclass features.
- Categories represent subclasses that can exist in multiple superclasses through a union.
- Constraints include disjointness, completeness, and whether subclasses are predicate-defined or user-defined.
Bài 1: Làm quen với SQL Server 2008 - Giáo trình FPTMasterCode.vn
Truy cập tới CSDL qua mạng
Hỗ trợ mô hình Client/Server
Kho dữ liệu (Data WareHouse)
Tương thích với chuẩn ANSI/ISO SQL -92
Hỗ trợ tìm kiếm Full- Text (Full- Text Search)
Hỗ trợ tìm kiếm thông tin trực tuyến (Books Online)
Các kiểu dữ liệu mới và các hàm thư viện làm việc với
các kiểu dữ liệu này như XML, Các kiểu dữ liệu giá trị lớn
(lưu ảnh, video…)
Hỗ trợ FileStream để thao tác với các đối tượng nhị phân
lớn (BLOB)
Language-Integrated Query (LINQ)
Hỗ trợ DotNet 3.5
……
Một số tính năng của SQL Server 2008
Các kiểu dữ liệu mới và các hàm thư viện làm việc với
các kiểu dữ liệu này như XML, Các kiểu dữ liệu giá trị lớn
(lưu ảnh, video…)
Hỗ trợ FileStream để thao tác với các đối tượng nhị phân
lớn (BLOB)
Language-Integrated Query (LINQ)
Hỗ trợ DotNet 3.5
……
Bài 4: Lập trình với CSDL ADO.NET & Kiến trúc không kết nối & Lập trình giao ...MasterCode.vn
Giới thiệu về ADO.NET
Các thành phần của ADO.NET
DataProvider
DataSet
Các loại DataProvider
Sql Data Provider
SqlConnection
SqlDataAdapter
Ứng dụng nhiều form
Ứng dụng SDI
Ứng dụng MDI
Thêm Toolbar, Tooltip vào form
The document discusses database triggers in MySQL. It defines a trigger as a set of SQL statements stored to be activated when a database event, such as an INSERT, UPDATE, or DELETE occurs on a table. Triggers can check integrity, catch errors in business logic, and automatically run tasks in response to table changes. The document provides examples of creating triggers to log changes to an employee table and check order quantities before an order. It also covers managing triggers through the INFORMATION_SCHEMA and DROP TRIGGER statement.
1. Hệ quản trị cơ sở dữ liệu
Giới thiệu
Dư Phương Hạnh
Bộ môn Hệ thống thông tin
Khoa CNTT, trường Đại học Công nghệ
Đại học Quốc gia Hanoi
hanhdp@vnu.edu.vn
2. Hệ quản trị CSDL
Database Management System (DBMS)
Là một tập các chương trình phần mềm giúp tổ
chức, lưu trữ, quản lý và truy xuất dữ liệu trong một
CSDL
2
Hệ quản trị CSDL @ BM HTTT
3. Hệ quản trị CSDL
Cung cấp truy cập đơn giản đến dữ liệu được lưu
trữ trong CSDL.
Một số mô hình lưu trữ:
–
–
–
–
–
Phân bậc (hierarchical model)
Mạng (network model)
Quan hệ (relational model)
Đa chiều (multidimensional model)
Đối tượng (object model)
Một Hệ quản trị CSDL có thể cung cấp một hoặc
nhiều mô hình lưu trữ
3
Hệ quản trị CSDL @ BM HTTT
4. Một số hệ quản trị CSDL quan hệ
4
IBM DB2
IBM Lotus
MySQL
Microsoft Access
Microsoft SQL Server
Microsoft FoxPro
Oracle
Postgre SQL
SQLite
…
Hệ quản trị CSDL @ BM HTTT
5. Mục tiêu của khóa học
Hướng thực hành
Sử dụng Hệ quản trị CSDL mã nguồn mở MySQL
Kiến thức đã học hỗ trợ: CSDL
5
Hệ quản trị CSDL @ BM HTTT
6. Cấu trúc tổng quan MySQL
6
Hệ quản trị CSDL @ BM HTTT
7. Cài đặt MySQL Database Server
Chạy trên nhiều nền tảng khác nhau: Linux,
Windows, Mac, FreeBSD, Unix...
MySQL được cài đặt từ bản cài (gói) hay biên dịch
từ mã nguồn
http://dev.mysql.com/downloads/
7
Hệ quản trị CSDL @ BM HTTT
9. Cấu hình cài đặt trên MS Windows
Developer Machine: thích hợp cho máy phát triển
Server Machine: thích hợp với ứng dụng web server
Dedicated Machine: thích hợp server chạy chủ yếu DB Server
9
Hệ quản trị CSDL @ BM HTTT
10. Cấu hình cài đặt trên MS Windows
10
Multifunctional DB: CSDL đa mục đích
Transactional DB: tối ưu cho ứng dụng giao dịch web
Non-Transactional DB: thích hợp cho ứng dụng web đơn giản, không
sử dụng giao dịch
Hệ quản trị CSDL @ BM HTTT
11. Cấu hình cài đặt trên MS Windows
Developer Machine: thích hợp cho máy phát triển
Server Machine: thích hợp với ứng dụng web server
Dedicated Machine: thích hợp server chạy chủ yếu DB Server
11
Hệ quản trị CSDL @ BM HTTT
12. Cấu hình cài đặt trên MS Windows
12
Decision Support: thích hợp với ứng dụng không yêu cầu số lượng
kết nối đồng thời cao
OLTP: thích hợp với ứng dụng yêu cầu số lượng kết nối đồng thời
cao, như webserver có tải lớn
Hệ quản trị CSDL @ BM HTTT
13. Cấu hình cài đặt trên MS Windows
Port Number: số cổng làm việc của MySQL server
Enable Strict Mode: không cho phép đưa các giá trị không hợp lệ vào
bảng dữ liệu: như dữ liệu ngoài vùng, NULL vào cột NOT NULL
13
Hệ quản trị CSDL @ BM HTTT
14. Cấu hình cài đặt trên MS Windows
Standard Character Set: ngầm định sử dụng tập chữ latin (ANSI)
Multilingualism: Unicode UTF8 được ngầm định sử dụng (thích hợp
với Việt Nam)
14
Hệ quản trị CSDL @ BM HTTT
15. Cấu hình cài đặt trên MS Windows
15
Tài khoản root: tài khoản gốc quản lý MySQL Server
Anonymous Account: nếu lựa chọn, thì người dùng bất kỳ có thể đăng
nhập vào hệ thống (chỉ nên sử dụng trong quá trình phát triển, kiểm
thử, không sử dụng khi triển khai hệ thống)
Hệ quản trị CSDL @ BM HTTT
16. Cấu trúc thư mục MySQL
Thư mục Nội dung
bin
data
Nơi MySQL đọc và ghi dữ liệu, và các file log của server
include
Tập các file header, sử dụng khi viết và biên dịch các chương trình
lib
Các file thư viện của MySQL
scripts
mysql_install_db script, được sử dụng để khởi tạo file dữ liệu và các tài
khoản
share
16
File nhị phân - mysqld chương trình server, tất cả các chương trình
khách và công cụ để sử dụng và quản trị MySQL
SQL scripts để sửa các đặc quyền, cũng như tập các file ngôn ngữ
Hệ quản trị CSDL @ BM HTTT
17. File cấu hình
my.ini hoặc my.cnf nếu sử dụng Windows
hoặc Linux, Unix, và Mac.
# The TCP/IP Port the MySQL Server will listen on
port=3306
# Path to installation directory. All paths are
# usually resolved relative to this.
basedir="C:/Program Files/MySQL/MySQL Server 5.5/"
# Path to the database root
datadir="C:/Program Files/MySQL/MySQL Server 5.5/Data/"
17
Hệ quản trị CSDL @ BM HTTT
18. Tài liệu tham khảo
http://www.mysql.com
http://dev.mysql.com/doc/refman/5.5/en/
http://www.mysqltutorial.org
18
Hệ quản trị CSDL @ BM HTTT