Download - Slide2 - Basis Data 2

Transcript
Page 1: Slide2 - Basis Data 2

Pertemuan ke 2 Tipe data & ERDKurniawan Eka Permana

Page 2: Slide2 - Basis Data 2

Basis Data RelationalStruktur:– tabel, kolom, dan tipe dataIntegritas:– unicity contraints, primary keys– NOT NULL constraint– Foreign keys– Other constraintsManipulasi data:– retrieving information– inserting, updating, and deleting data

Page 3: Slide2 - Basis Data 2

Structured Language Query (SQL)Terdiri dari:Data Definition Language (DDL):– CREATE tables, indexes, views, Establish

primary / foreign keys, DROP / ALTER tables .... Etc

Data Manipulation Language (DML):– INSERT / UPDATE / DELETE, SELECT .... etc.Data Control Language (DCL):– COMMIT / ROLLBACK work, GRANT /

REVOKE .... etc

Page 4: Slide2 - Basis Data 2

Statement Select

Page 5: Slide2 - Basis Data 2

DMLKlausa statemen SELECT:– FROM --> menentukan tabel(-tabel) sumber– WHERE --> memilih baris(-baris) yang memenuhi kondisi(-kondisi)– GROUP BY --> menggabungkan baris(-baris) yang

kolomnyamemiliki nilai yang sama– HAVING --> memilih grup yang memenuhi kondisi(-

kondisi)– SELECT --> memilih kolom(-kolom)– ORDER BY --> mengurutkan baris-baris berdasarkan

nilainilaiyang ada dalam kolom(-kolom)

Page 6: Slide2 - Basis Data 2

ContohSELECT * FROM employeeWHERE dno >1GROUP BY superssnHAVING COUNT( * ) >1ORDER BY salary

Page 7: Slide2 - Basis Data 2

Hasil FROM

WHERE

Page 8: Slide2 - Basis Data 2

Hasil…..lanjutan

ORDER BY

GROUP BY

HAVING

Page 9: Slide2 - Basis Data 2

Data table

EMPLOYEE

Nama tabel

Kolom

Baris

Nama kolom

DEPARTMENT

Page 10: Slide2 - Basis Data 2

Data table….lanjutanDEPENDENT

DEPARTMENT LOCATION PROJECT

Page 11: Slide2 - Basis Data 2

Tipe data numericBITA bit-field, from 1 to 64 bits wide. (Prior to MySQL 5 BIT

was functionally equivalent to TINYINT)BIGINT Integer value, supports numbers from -

9223372036854775808 to 9223372036854775807 (or 0 to 18446744073709551615 if UNSIGNED)

BOOLEAN (or BOOL)Boolean flag, either 0 or 1, used primarily for on/off flagsDECIMAL (or DEC)Floating point values with varying levels of precisionDOUBLEDouble-precision floating point valuesFLOATSingle-precision floating point values

Page 12: Slide2 - Basis Data 2

Tipe data numeric….. lanjutanINT (or INTEGER) Integer value, supports numbers from -2147483648 to

2147483647 (or 0 to 4294967295 if UNSIGNED)MEDIUMINT Integer value, supports numbers from -8388608 to 8388607

(or 0 to 16777215 if UNSIGNED)REAL4-byte floating point valuesSMALLINT Integer value, supports numbers from -32768 to 32767 (or

0 to 65535 if UNSIGNED)TINYINT Integer value, supports numbers from -128 to 127 (or 0 to

255 if UNSIGNED)

Page 13: Slide2 - Basis Data 2

Tipe data stringCHARFixed-length string from 1 to 255 chars long. Its size

must be specified at create time, or MySQL assumes CHAR(1)

ENUMAccepts one of a predefined set of up to 64K stringsLONGTEXTSame as TEXT, but with a maximum size of 4GBMEDIUMTEXTSame as TEXT, but with a maximum size of 16KSETAccepts zero or more of a predefined set of up to 64

strings

Page 14: Slide2 - Basis Data 2

Tipe data string….. lanjutan TEXT Variable-length text with a maximum size of 64K TINYTEXT Same as TEXT, but with a maximum size of 255 bytes VARCHAR Same as CHAR, but stores just the text. The size is a maximum,

not a minimum BLOB Blob with a maximum length of 64K MEDIUMBLOB Blob with a maximum length of 16MB LONGBLOB Blob with a maximum length of 4GB TINYBLOB Blob with a maximum length of 255 bytes

Page 15: Slide2 - Basis Data 2

Tipe data tanggalDATEDate from 1000-01-01 to 9999-12-31 in the format YYYY-

MM-DDTIMETime in the format HH:MM:SSYEARA 2 or 4 digit year, 2 digit years support a range of 70

(1970) to 69 (2069), 4 digit years support a range of 1901 to 2155

DATETIMEA combination of DATE and TIMETIMESTAMPFunctionally equivalent to DATETIME (but with a smaller

range)