Kamis, 08 November 2012

Praktikum 3 SMBD


1. Lengkapi Tabel pada Database Pelatihan dengan membuat dua table lagi yaitu Tabel Siswa dan Tabel Training
mysql> create database pelatihan;
Query OK, 1 row affected (0.02 sec)
mysql> use pelatihan;
Database changed

Tabel Dosen
mysql> create table dosen(nip char(10) primary key,nama char(30),alamat char(50),notelpon char(7));
Query OK, 0 rows affected (0.06 sec)

mysql> desc dosen;
+----------+----------+------+-----+---------+-------+
| Field    | Type     | Null | Key | Default | Extra |
+----------+----------+------+-----+---------+-------+
| nip      | char(10) | NO   | PRI | NULL    |       |
| nama     | char(30) | YES  |     | NULL    |       |
| alamat   | char(50) | YES  |     | NULL    |       |
| notelpon | char(7)  | YES  |     | NULL    |       |
+----------+----------+------+-----+---------+-------+
4 rows in set (0.02 sec)

mysql> desc siswa;
+----------+----------+------+-----+---------+-------+
| Field    | Type     | Null | Key | Default | Extra |
+----------+----------+------+-----+---------+-------+
| nrp      | char(10) | NO   | PRI | NULL    |       |
| nama     | char(30) | YES  |     | NULL    |       |
| alamat   | char(50) | YES  |     | NULL    |       |
| notelpon | char(7)  | YES  |     | NULL    |       |
+----------+----------+------+-----+---------+-------+
4 rows in set (0.02 sec)








mysql> desc training;
+---------------+-----------+------+-----+---------+-------+
| Field         | Type      | Null | Key | Default | Extra |
+---------------+-----------+------+-----+---------+-------+
| tanggal       | date(8)   | NO   | PRI | NULL    |       |
| kode_training | char(30)  | YES  |     | NULL    |       |
| nrp           | char(50)  | YES  | MUL | NULL    |       |
| nilai         | number(7) | YES  |     | NULL    |       |
+---------------+-----------+------+-----+---------+-------+
4 rows in set (0.02 sec)

2. Tulis Perintah SQL untuk membuat kedua table tersebut:
Tabel Siswa
mysql> create table siswa(nrp char(10) primary key,nama char(30),alamat char(50),notelpon char(7));
Query OK, 0 rows affected (0.06 sec)

Tabel Training
mysql> create table training(tanggal date(8) primary key,kode_training char(3)primary key,foreign key(nrp)references siswa (nrp) char(10),nilai number(7));
Query OK, 0 rows affected (0.06 sec)

Tidak ada komentar:

Posting Komentar