1. Trang chủ
  2. » Công Nghệ Thông Tin

nhập môn cơ sở dữ liệu - phần 5

51 662 1
Tài liệu đã được kiểm tra trùng lặp

Đ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

Tiêu đề Nhập môn cơ sở dữ liệu - phần 5
Tác giả ThS.Phan Võ Minh Thắng
Chuyên ngành Nhập môn Cơ sở dữ liệu
Thể loại Bài giảng
Định dạng
Số trang 51
Dung lượng 1,63 MB

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

Nội dung

Nội dung• Việc chuẩn hóa và việc mô hình E-R được dùng đồng thời với nhau để thực hiện tốt việc thiết kế CSDL • Trong một vài trường hợp yêu cầu phải de-normalization để phát sinh thông

Trang 1

Nhập môn Cơ sở Dữ liệu

Phần 5 – Chuẩn hóa

Trang 2

• Chuẩn hóa là gì, vai trò của nó trong việc

thiết kế CSDL

• Các dạng chuẩn 1NF, 2NF, 3NF, BCNF, và

4NF

• Cách chuyển từ dạng chuẩn thấp lên dạng

chuẩn cao hơn

Trang 3

Nội dung

• Việc chuẩn hóa và việc mô hình E-R được

dùng đồng thời với nhau để thực hiện tốt việc thiết kế CSDL

• Trong một vài trường hợp yêu cầu phải

de-normalization để phát sinh thông tin một cách hiệu quả

Trang 4

chuẩn hóa

• Bảng là thành phần cơ sở trong thiết kế CSDL

• Cấu trúc bảng là mối quan tâm hàng đầu

• Có hai trư trư ờng hợp:

– Vẫn có thể còn tồn tại các bảng có cấu trúc không tốt trong thiết kế CSDL hợp lý

– Hiệu chỉnh CSDL sẵn có, và cấu trúc các bảng không tốt

• Chuẩn hóa có thể giúp ta nhận biết các bảng có

cấu trúc không tốt và chuyển nó thành các bảng có cấu trúc tốt hơn

Trang 5

– Trải qua một dãi các bước gọi là các dạng chuẩn

Trang 6

• Các giai đoạn chuẩn hóa

– 1NF - First normal form – 2NF - Second normal form – 3NF - Third normal form – 4NF - Fourth normal form

Better in dependency

Worse in performance (I/O)

Business Bioinformatics Statistical data

Trang 7

Database Tables and

Trang 8

Ví dụ:

một mẫu báo cáo định kỳ tại công ty.

Trang 9

Table 4.1 should be here

Trang 10

Kết quả quan sát từ hình 4.1

• PRO_NUM intended to be primary key, but

it contains null values.

• Table entries invite data inconsistencies

Trang 12

Figure 4.2 is insert here.

Repeating group (any project can have a group of data entries) which should not to be appeared in relational table

Trang 13

Data Organization: 1NF

Figure 4.3

Trang 14

Conversion to 1NF

• Repeating groups must be eliminated

– Proper primary key developed

• Uniquely identifies attribute values (rows)

Trang 15

Conversion to 1NF

• Repeating groups must be eliminated

– Dependencies can be identified – Desirable dependencies based on primary key – Less desirable dependencies

Trang 16

Dependency Diagram (1NF)

Figure 4.4

Above: Desired Dependencies

Below: Less Desired Dependencies

Composite primary key

Trang 17

PROJ_NUM,EMP_NUM Æ PROJ_NAME, EMP_NAME,

Trang 18

1NF Summarized

• All key attributes defined

• No repeating groups in table

• All attributes dependent on primary key

Trang 19

Conversion to 2NF

• Start with 1NF format:

• Write each key component on separate line

• Write original key on last line

• Each component is new table

• Write dependent attributes after each key

PROJECT ( PROJ_NUM , PROJ_NAME)

EMPLOYEE ( EMP_NUM , EMP_NAME, JOB_CLASS, CHG_HOUR )

ASSIGN (PROJ_NUM, EMP_NUM, HOURS)

Trang 20

2NF Conversion Results

Figure 4.5

Trang 21

2NF Summarized

• In 1NF

• Includes no partial dependencies

– No attribute dependent on a portion of primary key

• Still possible to exhibit transitive dependency

– Attributes may be functionally dependent on

Trang 22

JOB (JOB_CLASS, CHG_HOUR)

Trang 23

3NF Summarized

• In 2NF

• Contains no transitive dependencies

Trang 24

Additional DB Enhancements

Figure 4.6

Trang 27

3NF Table Not in BCNF

Figure 4.7

Trang 28

Structure to Meet BCNF

Figure 4.8

Trang 29

Example: BCNF conversion

Trang 30

Decomposition into BCNF

Figure 4.9

Trang 31

Normalization and Database

Design

• Normalization should be part of the design

process

• Make sure the proposed entities meet the

required normal form before the table structures are created

• Used to redesign or modify the existing

table structures.

• E-R Diagram provides macro view

Trang 33

Normalization and Database

Design

• Contracting company’s example:

PROJECT (PROJ_NUM, PROJ_NAME)

EMPLOYEE(EMP_NUM, EMP_LNAME,EMP_FNAME,EMP_INITAL,

JOB_DESCRIPTION, JOB_CHG_HOUR);

Trang 34

Initial ERD for Contracting

Company

Figure 4.10

Already 3NF There is a transitive dependency

Trang 35

PROJECT (PROJ_NUM, PROJ_NAME)

EMPLOYEE(EMP_NUM, EMP_LNAME,EMP_FNAME,EMP_INITAL,

JOB_CODE) JOB (JOB_CODE, JOB_DESCRIPTION, JOB_CHG_HOUR);

Removal

Trang 36

Contracting Company

Trang 37

Final ERD for Contracting Company

Figure 4.12

Trang 38

PROJECT (PROJ_NUM, PROJ_NAME, EMP_NUM)

EMPLOYEE(EMP_NUM, EMP_LNAME,EMP_FNAME,EMP_INITAL,

EMP_HIREDATE, JOB_CODE) JOB (JOB_CODE,, JOB_DESCRIPTION, JOB_CHG_HOUR);

ASSIGN((ASSIGN_NUM, ASSIGN_DATE, ASSIGN_HOURS,

ASSIGN_CHG_HOURS, ASSIGN_CHARGE, EMP_NUM, PROJ_JUM)

Trang 40

Higher-Level Normal Forms

• Fourth Normal Form (4NF)

– Table is in 3NF – Has no multiple sets of multivalued dependencies

Trang 41

Conversion to 4NF

Figure 4.14

Figure 4.15 Set of Tables in 4NF

Trang 43

• Normalization purity is difficult to sustain due to conflict in:

– Design efficiency – Information requirements – Processing

Trang 44

Unnormalized Table Defects

• Data updates less efficient

• Indexing more cumbersome

• No simple strategies for creating views

Trang 45

INVOICE table structure

Draw dependency diagram Identify all dependencies 2NF?

Trang 47

Properties table structure

Trang 49

Dinner club table structure

Ngày đăng: 30/03/2014, 21:32

TỪ KHÓA LIÊN QUAN