Senin, 19 Desember 2011

MEMBUAT BASIS DATA KLINIK DENGAN MySQL

MEMBUAT BASIS DATA DENGAN MENGOPERASIKAN MYSQL.

Dengan data - data sebagai berikut :

> PASIEN

  - id_pasien => PK (Primary key)
  - nama
  - umur
  - jenkel
  - alamat
  - telp

> DOKTER

  - kd_dokter => PK (Primary key)
  - NmDokter
  - Spesialis
  - TelpDokter
  - AlmtDokter

> DIAGNOSA

  - id_pasien
  - tgl_berobat
  - kd_dokter
  - penyakit
  - obat
  - dosis

===========================================================================

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\WS19>cd\

C:\>cd xampp\mysql\bin

C:\xampp\mysql\bin>mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.1.41 Source distribution

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

mysql> create database klinik_wulan_sari;
Query OK, 1 row affected (0.00 sec)


mysql> use klinik_wulan_sari;
Database changed
mysql> create table pasien
    -> (
    -> id_pasien char(6) not null primary key,
    -> nama varchar(35) not null,
    -> umur char(2),
    -> Jenkel enum('L','P'),
    -> alamat varchar(25),
    -> Telp char(15)
    -> );
Query OK, 0 rows affected (0.03 sec)

mysql> create table dokter
    -> (
    -> kd_dokter char(6) not null primary key,
    -> NmDokter varchar(35) not null,
    -> Spesialis varchar(15),
    -> TelpDokter char(15),
    -> AlmtDokter varchar(35)
    -> );
Query OK, 0 rows affected (0.02 sec)

mysql> create table diagnosa
    -> (
    -> id_pasien char(6) not null primary key,
    -> tgl_berobat date,
    -> kd_dokter char(6) not null primary key,
    -> penyakit varchar(15),
    -> obat varchar(20),
    -> dosis char(5)
    -> );
ERROR 1068 (42000): Multiple primary key defined
mysql>  create table diagnosa
    -> (
    -> id_pasien char(6),
    -> tgl_berobat date,
    -> kd_dokter char(6),
    -> penyakit varchar(15),
    -> obat varchar(20),
    -> dosis char(5)
    -> );
Query OK, 0 rows affected (0.02 sec)

mysql> drop table diagnosa
    -> ();
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near '()' a
t line 2
mysql> drop table diagnosa;
Query OK, 0 rows affected (0.00 sec)

mysql> create table diagnosa
    -> (
    -> id_pasien char(6) not null,
    -> tgl_berobat date,
    -> kd_dokter char(6) not null,
    -> penyakit varchar(15),
    -> obat varchar(20),
    -> dosis char(5)
    -> );
Query OK, 0 rows affected (0.00 sec)

mysql> show tables;


mysql> alter table diagnosa add primary key (id_pasien,kd_dokter);
Query OK, 0 rows affected (0.05 sec)
Records: 0  Duplicates: 0  Warnings: 0