Sei sulla pagina 1di 11

Microsoft Windows [Version 10.0.

15063]

(c) 2017 Microsoft Corporation. All rights reserved.

--------------------------------------------- 1 ------------------------------------------

C:\Users\FallDown>xampp\mysql\bin\mysql.exe -u root -p

The system cannot find the path specified.

C:\Users\FallDown>cd..

C:\Users>cd..

C:\>xampp\mysql\bin\mysql.exe -u root -p

Enter password:

Welcome to the MariaDB monitor. Commands end with ; or \g.

Your MariaDB connection id is 2

Server version: 10.1.19-MariaDB mariadb.org binary distribution

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> create database akademik;

Query OK, 1 row affected (0.06 sec)

MariaDB [(none)]> show databases;

+--------------------+

| Database |

+--------------------+

| akademik |
| information_schema |

| mysql |

| performance_schema |

| perpustakaan |

| phpmyadmin |

| rumahsakit |

| test |

+--------------------+

8 rows in set (0.06 sec)

MariaDB [(none)]> use akademik;

Database changed

MariaDB [akademik]> show tables;

Empty set (0.00 sec)

MariaDB [akademik]> create table mahasiswa (NIM char(9), NAMA varchar(30) NOT NULL, NIP char(5),
primary key(NIM));

Query OK, 0 rows affected (0.38 sec)

MariaDB [akademik]> describe mahasiswa;

+-------+-------------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |

+-------+-------------+------+-----+---------+-------+

| NIM | char(9) | NO | PRI | NULL | |

| NAMA | varchar(30) | NO | | NULL | |

| NIP | char(5) | YES | | NULL | |

+-------+-------------+------+-----+---------+-------+

3 rows in set (0.05 sec)


MariaDB [akademik]> alter table mahasiswa add foreign key(NIP) references dosen(NIP) on update
cascade on delete cascade;

Query OK, 0 rows affected (0.90 sec)

Records: 0 Duplicates: 0 Warnings: 0

MariaDB [akademik]> describe mahasiswa;

+-------+-------------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |

+-------+-------------+------+-----+---------+-------+

| NIM | char(9) | NO | PRI | NULL | |

| NAMA | varchar(30) | NO | | NULL | |

| NIP | char(5) | YES | MUL | NULL | |

+-------+-------------+------+-----+---------+-------+

3 rows in set (0.02 sec)

MariaDB [akademik]> create table matakuliah (KODEMK char(5), NAMA varchar(30) NOT NULL, SKS
integer, primary key(KODEMK));

Query OK, 0 rows affected (0.30 sec)

MariaDB [akademik]> describe matakuliah;

+--------+-------------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |

+--------+-------------+------+-----+---------+-------+

| KODEMK | char(5) | NO | PRI | NULL | |

| NAMA | varchar(30) | NO | | NULL | |

| SKS | int(11) | YES | | NULL | |

+--------+-------------+------+-----+---------+-------+

3 rows in set (0.02 sec)


MariaDB [akademik]> create table dosen (NIP char(5), NAMA varchar(30) NOT NULL, primary key(NIP));

Query OK, 0 rows affected (0.66 sec)

MariaDB [akademik]> describe dosen;

+-------+-------------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |

+-------+-------------+------+-----+---------+-------+

| NIP | char(5) | NO | PRI | NULL | |

| NAMA | varchar(30) | NO | | NULL | |

+-------+-------------+------+-----+---------+-------+

2 rows in set (0.00 sec)

MariaDB [akademik]> create table kuliah (KODEKULIAH char(6), KODEMK char(5),NIP


char(5),THNAKADEMIK char(5), SEMESTER char(4),RUANGAN char(4), primary key(KODEKULIAH));

Query OK, 0 rows affected (0.32 sec)

MariaDB [akademik]> alter table kuliah add foreign key(KODEMK) references matakuliah(KODEMK) on
update cascade on delete cascade;

Query OK, 0 rows affected (0.98 sec)

Records: 0 Duplicates: 0 Warnings: 0

MariaDB [akademik]> alter table kuliah add foreign key(NIP) references dosen(NIP) on update cascade
on delete cascade;

Query OK, 0 rows affected (1.21 sec)

Records: 0 Duplicates: 0 Warnings: 0

MariaDB [akademik]> describe kuliah;

+-------------+---------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |

+-------------+---------+------+-----+---------+-------+
| KODEKULIAH | char(6) | NO | PRI | NULL | |

| KODEMK | char(5) | YES | MUL | NULL | |

| NIP | char(5) | YES | MUL | NULL | |

| THNAKADEMIK | char(5) | YES | | NULL | |

| SEMESTER | char(4) | YES | | NULL | |

| RUANGAN | char(4) | YES | | NULL | |

+-------------+---------+------+-----+---------+-------+

6 rows in set (0.02 sec)

MariaDB [akademik]> create table peserta (KODEKULIAH char(6), NIM char(9),NILAI char(1));

Query OK, 0 rows affected (0.57 sec)

MariaDB [akademik]> alter table peserta add foreign key(KODEKULIAH) references kuliah(KODEKULIAH)
on update cascade on delete cascade;

Query OK, 0 rows affected (0.73 sec)

Records: 0 Duplicates: 0 Warnings: 0

MariaDB [akademik]> alter table peserta add foreign key(NIM) references mahasiswa(NIM) on update
cascade on delete cascade;

Query OK, 0 rows affected (0.76 sec)

Records: 0 Duplicates: 0 Warnings: 0

MariaDB [akademik]> describe peserta;

+------------+---------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |

+------------+---------+------+-----+---------+-------+

| KODEKULIAH | char(6) | YES | MUL | NULL | |

| NIM | char(9) | YES | MUL | NULL | |

| NILAI | char(1) | YES | | NULL | |


+------------+---------+------+-----+---------+-------+

3 rows in set (0.02 sec)

--------------------------------------------- 2 ------------------------------------------

MariaDB [akademik]> insert into matakuliah values ('SD001','Struktur Data','3');

Query OK, 1 row affected (0.05 sec)

MariaDB [akademik]> insert into matakuliah values ('BS001','Basis Data','3');

Query OK, 1 row affected (0.06 sec)

MariaDB [akademik]> insert into matakuliah values ('KL001','Kalkulus I','3');

Query OK, 1 row affected (0.09 sec)

MariaDB [akademik]> select*from matakuliah;

+--------+---------------+------+

| KODEMK | NAMA | SKS |

+--------+---------------+------+

| BS001 | Basis Data | 3 |

| KL001 | Kalkulus I | 3 |

| SD001 | Struktur Data | 3 |

+--------+---------------+------+

3 rows in set (0.00 sec)

MariaDB [akademik]> insert into dosen values ('DS001','Steve Vai');

Query OK, 1 row affected (0.08 sec)

MariaDB [akademik]> insert into dosen values ('DS002','Paul Gilbert');

Query OK, 1 row affected (0.08 sec)


MariaDB [akademik]> insert into dosen values ('DS003','John Petruci');

Query OK, 1 row affected (0.08 sec)

MariaDB [akademik]> select*from dosen;

+-------+--------------+

| NIP | NAMA |

+-------+--------------+

| DS001 | Steve Vai |

| DS002 | Paul Gilbert |

| DS003 | John Petruci |

+-------+--------------+

3 rows in set (0.00 sec)

MariaDB [akademik]> insert into mahasiswa values ('E1E117001','Steven Tyler','DS001');

Query OK, 1 row affected (0.05 sec)

MariaDB [akademik]> insert into mahasiswa values ('E1E117002','John Bon Jovy','DS001');

Query OK, 1 row affected (0.05 sec)

MariaDB [akademik]> select*from mahasiswa;

+-----------+---------------+-------+

| NIM | NAMA | NIP |

+-----------+---------------+-------+

| E1E117001 | Steven Tyler | DS001 |

| E1E117002 | John Bon Jovy | DS001 |

+-----------+---------------+-------+

2 rows in set (0.00 sec)


MariaDB [akademik]> insert into kuliah values ('KLH001','SD001','DS001','20171','I','IT1');

Query OK, 1 row affected (0.06 sec)

MariaDB [akademik]> insert into kuliah values ('KLH002','BS001','DS002','20172','II','IT3');

Query OK, 1 row affected (0.06 sec)

MariaDB [akademik]> insert into kuliah values ('KLH003','KL001','DS003','20171','I','IT2');

Query OK, 1 row affected (0.06 sec)

MariaDB [akademik]> select*from kuliah;

+------------+--------+-------+-------------+----------+---------+

| KODEKULIAH | KODEMK | NIP | THNAKADEMIK | SEMESTER | RUANGAN |

+------------+--------+-------+-------------+----------+---------+

| KLH001 | SD001 | DS001 | 20171 |I | IT1 |

| KLH002 | BS001 | DS002 | 20172 | II | IT3 |

| KLH003 | KL001 | DS003 | 20171 |I | IT2 |

+------------+--------+-------+-------------+----------+---------+

3 rows in set (0.00 sec)

MariaDB [akademik]> insert into peserta values ('KLH001','E1E117001','A');

Query OK, 1 row affected (0.05 sec)

MariaDB [akademik]> insert into peserta values ('KLH002','E1E117001','B');

Query OK, 1 row affected (0.06 sec)

MariaDB [akademik]> insert into peserta values ('KLH003','E1E117001','B');

Query OK, 1 row affected (0.06 sec)

MariaDB [akademik]> insert into peserta values ('KLH001','E1E117002','C');


Query OK, 1 row affected (0.06 sec)

MariaDB [akademik]> insert into peserta values ('KLH002','E1E117002','B');

Query OK, 1 row affected (0.05 sec)

MariaDB [akademik]> insert into peserta values ('KLH003','E1E117002','B');

Query OK, 1 row affected (0.05 sec)

MariaDB [akademik]> select*from peserta;

+------------+-----------+-------+

| KODEKULIAH | NIM | NILAI |

+------------+-----------+-------+

| KLH001 | E1E117001 | A |

| KLH002 | E1E117001 | B |

| KLH003 | E1E117001 | B |

| KLH001 | E1E117002 | C |

| KLH002 | E1E117002 | B |

| KLH003 | E1E117002 | B |

+------------+-----------+-------+

6 rows in set (0.00 sec)

--------------------------------------------- 3a ------------------------------------------

MariaDB [akademik]> select P.NIM,P.NAMA,Ps.NAMA from mahasiswa p, matakuliah ps, peserta s,


kuliah k where p.NIM=s.NIM AND s.KOdEKULIAH=k.KODEKULIAH AND ps.KODEMK=k.KODEMK;

+-----------+---------------+---------------+

| NIM | NAMA | NAMA |

+-----------+---------------+---------------+

| E1E117001 | Steven Tyler | Struktur Data |


| E1E117001 | Steven Tyler | Basis Data |

| E1E117001 | Steven Tyler | Kalkulus I |

| E1E117002 | John Bon Jovy | Struktur Data |

| E1E117002 | John Bon Jovy | Basis Data |

| E1E117002 | John Bon Jovy | Kalkulus I |

+-----------+---------------+---------------+

6 rows in set (0.00 sec)

MariaDB [akademik]>

--------------------------------------------- 3b ------------------------------------------

MariaDB [akademik]> select P.NAMA, Ps.NAMA from dosen p, matakuliah ps, kuliah k where
p.NIP=k.NIP AND ps.KODEMK=k.KODEMK;

+--------------+---------------+

| NAMA | NAMA |

+--------------+---------------+

| Steve Vai | Struktur Data |

| Paul Gilbert | Basis Data |

| John Petruci | Kalkulus I |

+--------------+---------------+

3 rows in set (0.05 sec)

--------------------------------------------- 3c ------------------------------------------

MariaDB [akademik]> select P.NIM,P.NAMA,Ps.NAMA,s.NILAI from mahasiswa p, matakuliah ps, peserta


s, kuliah k where p.NIM=s.NIM AND s.KOdEKULIAH=k.KODEKULIAH AND ps.KODEMK=k.KODEMK AND
s.nilai='b';

+-----------+---------------+------------+-------+

| NIM | NAMA | NAMA | NILAI |

+-----------+---------------+------------+-------+

| E1E117001 | Steven Tyler | Basis Data | B |


| E1E117001 | Steven Tyler | Kalkulus I | B |

| E1E117002 | John Bon Jovy | Basis Data | B |

| E1E117002 | John Bon Jovy | Kalkulus I | B |

+-----------+---------------+------------+-------+

4 rows in set (0.00 sec)

MariaDB [akademik]> select P.NIM,P.NAMA,Ps.NAMA,s.NILAI from mahasiswa p, matakuliah ps, peserta


s, kuliah k where p.NIM=s.NIM AND s.KOdEKULIAH=k.KODEKULIAH AND ps.KODEMK=k.KODEMK AND
s.nilai='a';

+-----------+--------------+---------------+-------+

| NIM | NAMA | NAMA | NILAI |

+-----------+--------------+---------------+-------+

| E1E117001 | Steven Tyler | Struktur Data | A |

+-----------+--------------+---------------+-------+

1 row in set (0.00 sec)

MariaDB [akademik]> select P.NIM,P.NAMA,Ps.NAMA,s.NILAI from mahasiswa p, matakuliah ps, peserta


s, kuliah k where p.NIM=s.NIM AND s.KOdEKULIAH=k.KODEKULIAH AND ps.KODEMK=k.KODEMK AND
s.nilai='c';

+-----------+---------------+---------------+-------+

| NIM | NAMA | NAMA | NILAI |

+-----------+---------------+---------------+-------+

| E1E117002 | John Bon Jovy | Struktur Data | C |

+-----------+---------------+---------------+-------+

1 row in set (0.00 sec)