1. Trang chủ
  2. » Tất cả

Co so du lieu

455 3 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 455
Dung lượng 24,13 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

FIELD PROPERTIES 1/6FIELD PROPERTIES ASSOCIATED DATA TYPES USE Field Size Text Number AutoNumber Set the maximum size for stored data Format Text Memo Number Date/Time Currency AutoNumbe

Trang 1

CƠ SỞ DỮ LIỆU &

HỆ QUẢN TRỊ CƠ SỞ DỮ LIỆU

Trang 3

 Dữ liệu được mô tả dưới nhiều dạng khác nhau

 Kí tự, số, hình ảnh, kí hiệu, âm thanh

 Dữ liệu về đối tượng có thể khác nhau, tùy thuộc vào ngữ cảnh

 Ví dụ: dữ liệu về đối tượng sinh viên có thể khác nhau tùy thuộc vào mục đích quản lý

◦ Quản lý điểm: Tên, mã sinh viên, điểm thi

◦ Quản lý nhân thân: Tên, địa chỉ, ngày sinh, quê quán, lớp

3

Trang 4

CƠ SỞ DỮ LIỆU (DATABASE)

CSDL là tập hợp dữ liệu được tổ chức có cấu trúc

và được lưu trữ trong máy tính

 Danh sách sinh viên

 Niên giám điện thoại

CSDL được thiết kế, xây dựng cho phép người

dùng lưu trữ dữ liệu, truy xuất thông tin hoặc cậpnhật dữ liệu

Tập ngẫu nhiên của các dữ liệu không thể xem là

một CSDL

4

Trang 5

CƠ SỞ DỮ LIỆU QUAN HỆ (1/2)

Dữ liệu được biểu diễn dưới dạng bảng

 CSDL là tập hợp các bảng (table)

 Mỗi hàng là một bảng ghi (record)

 Mỗi cột là một thuộc tính (field)

Dữ liệu trong hai bảng liên hệ với nhau thông qua

các cột chung

Khóa

 Khóa chính (primary key)

 Khóa thay thế (alternate key)

 Khóa ngoài (foreign key)

5

Trang 6

CƠ SỞ DỮ LIỆU QUAN HỆ (2/2)

Ví dụ:

6

Trang 7

HỆ QUẢN TRỊ CSDL

Hệ quản trị CSDL (Database Management System)

là các phần mềm giúp tạo các CSDL và cung cấp

cơ chế lưu trữ, truy cập theo các mô hình CSDL

Ví dụ

 SQL Server, Microsoft Access, Oracle là các HQTCSDL

cho mô hình quan hệ

 IMS là HQTCSDL cho mô hình phân cấp

 IDMS là HQTCSDL cho mô hình mạng

7

Trang 8

HỆ QUẢN TRỊ CSDL QUAN HỆ

Relational Database Management System

Dữ liệu được tổ chức chặt chẽ dưới dạng các

bảng dữ liệu

Tất cả các thao tác trên CSDL đều diễn ra trên các

bảng

8

Trang 9

TỔNG QUAN VỀ

MICROSOFT ACCESS 2010

Trang 11

MS ACESS LÀ GÌ?

Nằm trong bộ MS Office

Là hệ quản trị cơ sở dữ liệu quan hệ

Phù hợp với các bài toán quản lý vừa và nhỏ

Trang 12

KHỞI ĐỘNG MS ACCESS

Start/ All Program/ Microsoft Office/ Microsoft

Access 2010

12

Trang 13

13

Trang 14

QUICK ACCESS TOOLBAR

14

Trang 15

Thanh ribbon

Hiện thị tên của các phím tắt: Alt/ F10

15

Trang 17

TẠO TẬP TIN CSDL (1/2)

Tạo CSDL mới, rỗng

17

Trang 18

TẠO TẬP TIN CSDL (2/2)

Tạo CSDL theo mẫu

18

Trang 19

QUẢN LÝ CSDL (1/3)

Mở tệp tin CSDL

19

Trang 20

QUẢN LÝ CSDL (2/3)

Thu gọn và chỉnh sửa CSDL

20

Trang 21

QUẢN LÝ CSDL (3/3)

Tạo và gỡ bỏ password

 Mở tệp tin ở chế độ Exclusive

21

Trang 22

ĐỐI TƯỢNG CỦA CSDL TRONG ACCESS

Bảng (Table)

Truy vấn (Query)

Biểu mẫu (Form)

Báo cáo (Report)

Tập lệnh (Macro)

Bộ mã lệnh (Module)

22

Trang 23

THAO TÁC VỚI CÁC ĐỐI TƯỢNG

Tạo mới một đối tượng

Thiết kế lại một đối tượng

Xem nội dung trình bày của một đối tượng

Xóa một đối tượng

Đổi tên đối tượng

Sao chép một đối tượng

Chép dữ liệu từ Access sang ứng dụng khác

(export) và ngược lại (import)

Chức năng Link

23

Trang 24

TẠO MỚI MỘT ĐỐI TƯỢNG

24

Trang 25

THIẾT KẾ LẠI MỘT ĐỐI TƯỢNG

Đối tượng đang mở

25

Trang 26

XEM NỘI DUNG TRÌNH BÀY CỦA MỘT

ĐỐI TƯỢNG

Đối tượng đang mở

26

Trang 27

XÓA MỘT ĐỐI TƯỢNG

27

Trang 28

ĐỔI TÊN ĐỐI TƯỢNG

28

Trang 29

SAO CHÉP MỘT ĐỐI TƯỢNG

1

2

3

29

Trang 30

Xuất dữ liệu sang CSDL Access khác hoặc Excel,

Word, Pdf, Email

30

Trang 31

Sao chép dữ liệu từ ứng dụng khác như Excel,

ODBC DB, XML File, Access … vào CSDL hiện hành

31

Trang 33

CHỌN GIAO DIỆN NGƯỜI DÙNG (1/3)

33

Trang 34

CHỌN GIAO DIỆN NGƯỜI DÙNG (2/3)

Overlapping windows

34

Trang 35

CHỌN GIAO DIỆN NGƯỜI DÙNG (3/3)

35

Trang 36

BẢNG DỮ LIỆU (TABLES)

Trang 38

 Khóa chính (primary key)

 Khóa ngoại (foreign key)

Trang 39

VÍ DỤ

Trang 40

KHÓA CHÍNH (PRIMARY KEY)

 Là tập hợp của một hay nhiều cột

 Dùng để phân biệt giữa các dòng khác nhau trong cùng

một bảng

 Khóa chính phải là duy nhất, không được trùng và không

phép rỗng

Trang 41

KHÓA NGOẠI (FOREIGN KEY)

là khóa chính của một bảng khác

Trang 42

TẠO BẢNG BẰNG TABLE DESIGN (1/4)

Trang 43

Field Properties

Trang 44

TẠO BẢNG BẰNG TABLE DESIGN (3/4)

Xác định khóa chính

 Lựa chọn thuộc tính (hoặc các thuộc tính) được sử dụng làm khóa chính

 Chọn nút Primary Key trên Table tools

 Hoặc R-click trên tên thuộc tính, chọn Primary Key

Trang 45

TẠO BẢNG BẰNG TABLE DESIGN (4/4)

Lưu bảng vừa tạo

 Sử dụng nút Save trên Quick Access Toolbar, hoặc Save trong tab File, hoặc Ctrl+S

 Đặt tên cho bảng

Trang 46

TẠO BẢNG TRONG CHẾ ĐỘ DATASHEET VIEW (1/2)

Trang 47

TẠO BẢNG TRONG CHẾ ĐỘ DATASHEET VIEW (2/2)

Trang 48

CÁC KIỂU DỮ LIỆU (DATA TYPES) (1/4)

Trang 49

DATA TYPES (2/4)

DATA TYPES USE SIZE

Text Use for alphanumeric character Up to 255 characters

Memo Use for text greater than 255

characters in length Up to 65,535 charactersNumber Use for storing numeric values

1, 2, 4, 8 or 12 bytes (16 bytes when used for replication ID)

Date/Time Use for storing date and time values 8 bytes

Currency Use for storing monetary values 8 bytes

AutoNumber Use for generating unique values

that can be used as a primary key

4 bytes (16 bytes when used for replication ID)

Trang 50

DATA TYPES (3/4)

DATA TYPES USE SIZE

Yes/No Use for Boolean values 1 bit

OLE Object

Use to hold a graphic or other objects Objects can be linked or embedded

Up to 1 GB

Attachment Use to attach a file to a record

(similar to file attachment in email)

2 GB for compressed attachments, ~700KB for uncompressed ones

Hyperlink Use for storing hyperlink Up to 65,535 characters

Trang 51

Note: Lookup Wizard is not an actual data type

• If the lookup field is bound to a table or a query, the size of the bound column is used

• Otherwise, the size of text field is used

Calculated *

Use to hold the results of a calculation based on other fields in the same tables

Rich text

Use for text fields that require up

to 65,535 alphanumeric characters with character formatting

Trang 52

FIELD PROPERTIES (1/6)

FIELD PROPERTIES ASSOCIATED DATA TYPES USE

Field Size

Text Number AutoNumber

Set the maximum size for stored data

Format

Text Memo Number Date/Time Currency AutoNumber Yes/No

Hyperlink

Customize the way that the field appears by default when it is displayed or printed

Decimal Places Number

Currency

Specify the number of decimal places to use when displaying numbers

Trang 53

FIELD PROPERTIES (2/6)

FIELD PROPERTIES ASSOCIATED DATA TYPES USE

New Values AutoNumber Incremented or random value is used

Input Mask

Text Number Date/Time Currency

Display editing characters to guide data entry

Caption All data types Set default labels for forms, reports, and

queries

Default Value

Text Memo Number Date/Time Currency Yes/No Hyperlink

Automatically assign the specified value

to a field when a new record is added

Trang 54

FIELD PROPERTIES (3/6)

FIELD PROPERTIES ASSOCIATED DATA TYPES USE

Validation Rule

Text Memo Number Date/Time Currency Yes/No Hyperlink

Supply an expression that must be true

to add or change the value in this field

Validation Text

Text Memo Number Date/Time Currency Yes/No Hyperlink

Enter text that appears when a value entered this field violates the expression

in the Validation Rule box

Trang 55

FIELD PROPERTIES (4/6)

FIELD PROPERTIES ASSOCIATED DATA TYPES USE

Required All data types except

Allow entry (by setting to Yes) of a length string (“”)

zero-Indexed

Text Memo Number Date/Time Currency AutoNumber Yes/No

Hyperlink

Speed up read access to data in this field

by creating and using an index

Trang 56

FIELD PROPERTIES (5/6)

FIELD PROPERTIES ASSOCIATED DATA TYPES USE

Unicode Compression

Text Memo Hyperlink

Compress the data in this field when fewer than 4,096 characters

IME Mode

Text Memo Date/Time Hyperlink

Control conversion of characters in East-Asian versions of Windows

IME Sentence Mode

Text Memo Date/Time Hyperlink

Control conversion of sentences in East-Asian versions of Windows

Trang 57

FIELD PROPERTIES (6/6)

FIELD PROPERTIES ASSOCIATED DATA TYPES USE

Smart Tags

Text Memo Number Date/Time Currency AutoNumber Hyperlink

Attach a smart tag to the field

Append Only Memo

Hyperlink Track field value history

Text Format Memo Select Rich Text to store field data as

HTML, Plan Text to store only text

Text Align All data types except

Attachment Specify default alignment of textShow Date Picker Date/Time Display a date picker

Trang 58

FIELD PROPERTIES – FIELD SIZE

DATA TYPES VALUE Expressed data

Text 1 - 255

Number

Byte Integers from 0 to 255 Integer Integers from -32,768 to 32,767 Long integer Integers from -2,147,483,648 to 2,147,483,647 Single Float from -3.4x10 38 to 3.4x10 38 and up to 7 significant digits Double Float from -1.797x10 308 to 1.797x10 308 and up to 15

significant digits Replication ID Globally unique identifier for replication (16 bytes for

storage) Decimal From -10 28 -1 to 10 28 -1, and up to 20 significant digits AutoNumber Long integer

ReplicationID

Trang 59

FIELD PROPERTIES – FORMAT

Custom text format

Ví dụ: @”.com”; “no link”[red]

Trang 60

FIELD PROPERTIES – FORMAT

Predefined Number format

Trang 61

FIELD PROPERTIES – FORMAT

Custom Number format (1/2)

Trang 62

FIELD PROPERTIES – FORMAT

Custom Number format (2/2)

 Custom number formats can have one to four sections with semicolons (;)

 Example

Trang 63

FIELD PROPERTIES – FORMAT

Predefined Date/Time format (1/4)

Trang 64

FIELD PROPERTIES – FORMAT

Custom Date/Time format (2/4)

Trang 65

FIELD PROPERTIES – FORMAT

Custom Date/Time format (3/4)

Trang 66

FIELD PROPERTIES – FORMAT

Custom Date/Time format (4/4)

Example:

 Define a custom format to display the date as:

15-April-2010

Trang 67

FIELD PROPERTIES – FORMAT

Predefined format of a Yes/No field

 Yes/No, True/False, On/Off

Custom format of a Yes/No field

 Contain up to three sections

 Example: Define custom format

◦ Display the word “Always” in blue text for Yes, True, or On

◦ And the word “Never” in red text for No, False, or Off

Trang 68

FIELD PROPERTIES – INPUT MASK

Quy định khuôn dạng của dữ liệu được nhập vào

Khi quy đinh Input Mask cho bảng, các Input

Mask này sẽ được áp dụng cho cả biểu mẫu

(form), truy vấn (query), và báo cáo (report)

Các ký tự sử dụng trong Input Mask

Trang 69

FIELD PROPERTIES – INPUT MASK

Các ký tự sử dụng trong Input Mask

Trang 70

FIELD PROPERTIES – INPUT MASK

Ví dụ 1

Ví dụ 2

 Tạo Input Mask cho trường Số điện thoại dưới dạng

### - ### - ####

Trang 71

FIELD PROPERTIES – VALIDATION RULE

Types of validation rule

 Field validation: Access uses the validation rule to test

an entry when you attempt to leave the field

 Record validation: Access uses the rule to test the

contents of more than one field when you attempt to leave the record

Create a validation rule

 A validation rule is an expression

 Logical, comparison and arithmetic operators are used

to build the expression

Trang 72

FIELD PROPERTIES – VALIDATION RULE

 Thiết lập validation rule cho trường ngày sinh, sao cho ngày

sinh được nhập vào nằm trong khoảng 1/1/2000 đến

1/1/2014

 Nếu ngày sinh nhập vào nằm ngoài khoảng quy đinh xuất

hiện hộp thoại yêu cầu nhập lại với lời nhắn “Nhập ngày sinh trong khoảng 1/03/2014 đến 31/03/2014”

Trang 73

FIELD PROPERTIES – VALIDATION RULE

Trang 74

BÀI TẬP 1

Tạo CSDL tên QLSV.ACCDB

TABLE NAME: LOP

Field Name Data Type Description Field Properties

MaLop Text Mã lớp

• Field size = 10

• Format: Chữ hoa, màu xanh

• Caption: Mã lớp TenLop Text Tên lớp • Field size = 30

• Caption: Tên lớp GVCN Text Giáo viên chủ

nhiệm • Field size = 30

Trang 75

BÀI TẬP 1

TABLE NAME: MONHOC

Field Name Data Type Description Field Properties

MaMH Text Mã môn học

• Field size = 10

• Format: Chữ hoa, màu đỏ

• Caption: Mã môn học TenMH Text Tên môn học • Field size = 30

• Caption: Tên môn học

SoTC Number Số tín chỉ

• Field size = byte

• Caption: Số tín chỉ

• Validation rule: Số tín chỉ nằm trong khoảng (1, 5)

Trang 76

BÀI TẬP 1

TABLE NAME: SINHVIEN

Field Name Data Type Description Field Properties

MaSV Text Mã sinh viên

• Field size = 10

• Format: Chữ hoa, màu đỏ

• Caption: Mã sinh viên HoSV Text Họ sinh viên • Field size = 30

• Caption: Họ sinh viên TenSV Text Tên sinh viên • Field size = 50

• Caption: Tên sinh viên GioiTinh Yes/No Giới tinh • Format: Nam/Nữ

• Caption: Giới tính

Trang 77

BÀI TẬP 1

TABLE NAME: SINHVIEN (tiếp)

Field Name Data Type Description Field Properties

NgaySinh Date/Time Ngày sinh

• Format: Short date

• Input mask: 00/00/00

• Caption: Ngày sinh

• Validation rule: Sinh trong khoảng 1/1/1980 đến 31/12/1995

DiaChi Text Địa chỉ • Caption: Địa chỉ

DienThoai Text Điện thoại • Input mask: (###) #######

• Caption: Điện thoại MaLop Text Mã lớp

• Field size = 10

• Format: chữ hoa, màu xanh

• Caption: Mã lớp

Trang 78

BÀI TẬP 1

TABLE NAME: KETQUA

Field Name Data Type Description Field Properties

MaSV

Text (Lookup Wizard)

Mã sinh viên

• Field size = 10

• Format: chữ hoa, màu xanh

• Caption: Mã sinh viên MaMH

Text (Lookup Wizard)

Mã môn học

• Field size = 10

• Format: Chữ hoa, màu đỏ

• Caption: Mã môn học DiemLan1 Number Điểm lần 1

• Field size: double

Trang 79

BÀI TẬP 1

Trang 82

Bảng SINHVIEN (tiếp)

Trang 83

BÀI TẬP 1

Trang 85

Tạo tập tin CSDL tên HOADON.ACCDB

TABLE NAME: NHANVIEN

Field Name Data Type Description Field Properties

MaNV AutoNumber Mã nhân viên • Caption: Mã nhân viên

HoNV Text Họ nhân viên

• Field size = 30

• Format: chữ hoa, màu xanh

• Caption: Họ nhân viên TenNV Text Tên nhân viên

• Field size = 50

• Format: chữ hoa, màu xanh

• Caption: Tên nhân viên GioiTinh Yes/No Giới tinh • Format: Nam/Nữ

• Caption: Giới tính

Trang 86

BÀI TẬP 2

TABLE NAME: NHANVIEN (tiếp)

Field Name Data Type Description Field Properties

NgaySinh Date/Time Ngày sinh

• Format: Short date

• Input mask: 00-00-00

• Caption: Ngày sinh DiaChi Text Địa chỉ • Caption: Địa chỉ

DienThoai Text Điện thoại • Input mask: (###) #######

• Caption: Điện thoại MaLop Text Mã lớp

• Field size = 10

• Format: chữ hoa, màu xanh

• Caption: Mã lớp Hình OLE Object Hình

Trang 87

BÀI TẬP 2

TABLE NAME: KHACHHANG

Field Name Data Type Description Field Properties

• Caption: Tên khách hàng DiaChi Text Địa chỉ • Field size = 50

• Caption: Địa chỉ ThanhPho Text Thành phố • Field size = 20

• Caption: Thành phố DienThoai Text Điện thoại • Input mask: (###) #######

• Caption: Điện thoại

Trang 88

BÀI TẬP 2

TABLE NAME: SANPHAM

Field Name Data Type Description Field Properties

MaSP Number Mã sản phẩm

• Field size = Integer

• Caption: Mã sản phẩm

• Required: Yes TenSP Text Tên sản phẩm

• Field size = 40

• Format: Chữ hoa, màu xanh

• Caption: Tên sản phẩm DonViTinh Text Đơn vị tính • Field size = 10

• Caption: Đơn vị tính DonGia Currency Đơn giá

• Format: Currency

• Caption: Đơn giá

• Validation text: Giá phải lớn hơn 0

Trang 89

BÀI TẬP 2

TABLE NAME: HOADON

Field Name Data Type Description Field Properties

MaHD Text Mã hóa đơn

• Field size = 5

• Format: Chữ hoa, màu đỏ

• Caption: Mã hóa đơn

• Field size: long integer

• Caption: Mã nhân viên

• Required: yes

Trang 90

BÀI TẬP 2

TABLE NAME: HOADON (tiếp)

Field Name Data Type Description Field Properties

NgayLapHD Date/Time Ngày lập

• Format: short date

• Caption: Ngày giao hàng

• Input mask 00/00/00

• Validation rule: ngày giao hàng phải sau ngày lập hóa đơn

Trang 91

BÀI TẬP 2

TABLE NAME: CHITIETHOADON

Field Name Data Type Description Field Properties

MaHD

Text (Lookup Wizard)

Mã hóa đơn

• Field size = 5

• Format: Chữ hoa, màu đỏ

• Caption: Mã hóa đơn

• Required: Yes MaSP

Number (Lookup Wizard)

Mã sản phẩm

• Field size = Integer

• Caption: Mã sản phẩm

• Required: Yes

SoLuong Number Số lượng

• Field size = Integer

• Format: standard

• Caption: Số lượng

• Validation rule: Số lượng phải >0 DonGiaBan Currency Đơn giá bán • Caption: Đơn giá bán

Trang 92

BÀI TẬP 2

Nhập dữ liệu vào file Excel sau đó Import vào

CSDL này

Trang 93

BÀI TẬP 2

Trang 98

BẢNG DỮ LIỆU (TABLES)

Trang 100

TẠO QUAN HỆ GIỮA CÁC BẢNG

Trang 101

CÁC LOẠI QUAN HỆ TRONG ACCESS

Quan hệ 1-1: Một bản ghi của bảng này sẽ liên

kết với duy nhất một bản ghi của bảng kia vàngược lại

Trang 102

CÁC LOẠI QUAN HỆ TRONG ACCESS

Quan hệ 1-n: Mỗi bản ghi của bảng 1 sẽ liên kết

với một hoặc nhiều bản ghi của bảng 2, ngược lạimột bản ghi của bảng 2 chỉ liên kết với một bảnghi của bảng 1

Trang 103

CÁCH TẠO QUAN HỆ (1/5)

Trang 105

Kéo trường quan hệ từ bảng này sang bản ghi

 Ví dụ: kéo trường MaSV từ bảng SINHVIEN sang MaSV của bảng KETQUA

Ngày đăng: 22/09/2019, 11:45

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN

w