Download ppt - SQL DDL

Transcript

DBST 652 3-1

SQL DDLSQL DDL

• Language used to define objects such as tables,

indexes, primary keys, foreign keys

• Used by most relational databases

DBST 652 3-2

SQL Syntax (1)SQL Syntax (1)

Elmasri, p. 289

DBST 652 3-3

SQL Syntax (2)SQL Syntax (2)

DBST 652 3-4

SQL2 Statements Defining COMPANY Schema (1)SQL2 Statements Defining COMPANY Schema (1)

Elmasri, p. 245

DBST 652 3-5

SQL2 Statements Defining COMPANY Schema (2)SQL2 Statements Defining COMPANY Schema (2)

DBST 652 3-6

Specifying Referential Triggered ActionsSpecifying Referential Triggered Actions

Elmasri, p. 248

DBST 652 3-7

SQL DDLSQL DDL

• Look in workbook at p. 22 and 27

• Translated ERD to DDL

• Look at structure of scripts – spool, drops,

creates, query catalog.

DBST 652 3-8

SQL DDLSQL DDL

• Space gets allocated on disks so we need to pay

attention to disk structure

• DBA may have to “place” objects (today)

DBST 652 3-9

Why important for us?Why important for us?

• When we use DDL and say CREATE TABLE or

CREATE INDEX, what happens?

• What options does the engine provide?

• Different engines may provide ability to control

data storage option or index option

DBST 652 3-10

Characteristics of Disk SystemsCharacteristics of Disk Systems

Stallings, p. 158

DBST 652 3-11

DisksDisks

Single-sided disk

Disk Pack

Elmasri, p 468

DBST 652 3-12

Multiple-Platter DiskMultiple-Platter Disk

Stallings, p. 160

DBST 652 3-13

Disk Data LayoutDisk Data Layout

Stallings, p. 156

DBST 652 3-14

Tracks divided into Blocks Tracks divided into Blocks

• Blocks is where database people get involved

because

• 1. It is our unit of I/O (could be multiblock)

• 2. We use it as our sizing unit

• Disks are where we place objects

• Assume dbcourse2 has 2k blocks

DBST 652 3-15

Winchester Disk Track Format (Seagate ST506)Winchester Disk Track Format (Seagate ST506)

Stallings, p. 157

DBST 652 3-16

Fixed and Moveable Head DisksFixed and Moveable Head Disks

Stallings, p. 159

DBST 652 3-17

Group of Sectors That Subtend the Same AngleGroup of Sectors That Subtend the Same Angle

Elmasri, p. 469

DBST 652 3-18

Interleaved vs. Simultaneous ConcurrencyInterleaved vs. Simultaneous Concurrency

Elmasri, p. 474

DBST 652 3-19

Double bufferingDouble buffering

• Shown on next slide

• cpu starts processing a block once transfer to

main memory is completed

• at same time - disk I/O processor can be reading

and transferring the next block into a different

buffer

DBST 652 3-20

Use of Two Buffers for Reading from DiskUse of Two Buffers for Reading from Disk

Elmasri, p. 474

DBST 652 3-21

Double bufferingDouble buffering

• “…Eliminates seek time and rotational delay for

all but first block”

• So…improves performance!

DBST 652 3-22

DDL creates objects on disk DDL creates objects on disk

• Go back to idea of DDL and what happens

• Relate DDL to disk layout here

• What happens on disk when you execute DDL?


Recommended