0% found this document useful (0 votes)
64 views3 pages

Nama: Yohana Febriyanti Manik NPM: 219530011 Kelas: 2 Ipti Mata Kuliah: Praktek Sistem Basis Data

The document contains details about creating databases and tables in MySQL using MariaDB. It provides the name, student number, and class of the student. It then shows the creation of a database called "db_ud_serbaguna" and tables called "tbl_barang", "tbl_supplier", "tbl_pembeli", "tbl_pembayaran", and "tbl_transaksi" with various columns and data types. Foreign keys are added to define relationships between the tables.

Uploaded by

yuda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views3 pages

Nama: Yohana Febriyanti Manik NPM: 219530011 Kelas: 2 Ipti Mata Kuliah: Praktek Sistem Basis Data

The document contains details about creating databases and tables in MySQL using MariaDB. It provides the name, student number, and class of the student. It then shows the creation of a database called "db_ud_serbaguna" and tables called "tbl_barang", "tbl_supplier", "tbl_pembeli", "tbl_pembayaran", and "tbl_transaksi" with various columns and data types. Foreign keys are added to define relationships between the tables.

Uploaded by

yuda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Nama : Yohana Febriyanti Manik

Npm : 219530011
Kelas : 2 IPTI
Mata kuliah : Praktek sistem basis data

Microsoft Windows [Version 10.0.10240]

(c) 2015 Microsoft Corporation. All rights reserved.

C:\Users\WI>Cd /xampp/mysql/bin

C:\xampp\mysql\bin>Mysql -u root

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

Your MariaDB connection id is 8

Server version: 10.4.11-MariaDB mariadb.org binary distribution

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

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

MariaDB [(none)]> create database db_ud_serbaguna;

Query OK, 1 row affected (0.002 sec)

MariaDB [(none)]> show databases;

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

| Database |

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

| db_ud_serbaguna |

| information_schema |
| mysql |

| performance_schema |

| phpmyadmin |

| test |

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

6 rows in set (0.003 sec)

MariaDB [db_ud_serbaguna]> use db_ud_serbaguna;

Database changed

Latihan 1 :

create table tbl_barang


(id_barang char(10) not null primary key,
nama_barang varchar(50) not null,
harga int not null,
id_suplier char(10) not null);

create table tbl_supplier


(id_suplier char(10) not null primary key,
nama_suplier varchar(50) not null,
alamat varchar(50) not null,
no_telp varchar(12) not null);

create table tbl_pembeli


(id_pembeli char(10) not null primary key,
nama_pembeli varchar(50) not null,
jenkel varchar(20) not null,
alamat varchar(50) not null,
no_telp varchar(12) not null);

create table tbl_pembayaran


(id_bayar char(10) not null primary key,
tgl_bayar date not null,
total_bayar double(50) not null,
id_transaksi char(10) not null,
Alter table tbl_pembayaran add foreign key (id_transaksi) references tbl_pembayaran (id_transaksi) );
create table tbl_transaksi
(id_transaksi char(10) not null primary key,
Id_barang char(10) not null,
Alter table tbl_transaksi add foreign key (id_barang) references tbl_barang (id_barang),
Id_pembeli char(10) not null,
Alter table tbl_transaksi add foreign key (id_pembeli) references tbl_pembeli (id_pembeli),
tgl date not null,
keterangan varchar(20) not null);

Latihan 2

perintah 1 :

menambahkan query foreign key pada tiap relasi tabel latihan 1, serta penentuan child dan parent :

 qurery foreign 1 :

id_transaksi char(10) not null,


Alter table tbl_pembayaran add foreign key (id_transaksi) references tbl_pembayaran
(id_transaksi) );

 Query foreign 2 :

Id_barang char(10) not null,


Alter table tbl_transaksi add foreign key (id_barang) references tbl_barang (id_barang),

 Qurery foreign 3 :

Id_pembeli char(10) not null,


Alter table tbl_transaksi add foreign key (id_pembeli) references tbl_pembeli (id_pembeli),

You might also like