Created
November 26, 2016 13:45
-
-
Save ardianta/7ae139c95570a35d3af9dc40b70f18db to your computer and use it in GitHub Desktop.
Contoh penyimpanan graf dalam tabel MySQL dengan metode Table Closure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- phpMyAdmin SQL Dump | |
-- version 4.5.4.1deb2ubuntu2 | |
-- http://www.phpmyadmin.net | |
-- | |
-- Host: localhost | |
-- Generation Time: Nov 26, 2016 at 10:39 PM | |
-- Server version: 5.7.16-0ubuntu0.16.04.1 | |
-- PHP Version: 7.0.8-0ubuntu0.16.04.3 | |
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; | |
SET time_zone = "+00:00"; | |
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; | |
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; | |
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; | |
/*!40101 SET NAMES utf8mb4 */; | |
-- | |
-- Database: `contoh_graf` | |
-- | |
-- -------------------------------------------------------- | |
-- | |
-- Table structure for table `jalan` | |
-- | |
CREATE TABLE `jalan` ( | |
`kota_asal` int(11) DEFAULT NULL, | |
`kota_tujuan` int(11) DEFAULT NULL, | |
`panjang` int(11) DEFAULT NULL | |
) ENGINE=InnoDB DEFAULT CHARSET=latin1; | |
-- | |
-- Dumping data for table `jalan` | |
-- | |
INSERT INTO `jalan` (`kota_asal`, `kota_tujuan`, `panjang`) VALUES | |
(1, 2, 14), | |
(1, 3, 10), | |
(2, 3, 6), | |
(2, 4, 18), | |
(3, 4, 7), | |
(4, 3, 9), | |
(5, 6, 8), | |
(6, 4, 11); | |
-- -------------------------------------------------------- | |
-- | |
-- Table structure for table `kota` | |
-- | |
CREATE TABLE `kota` ( | |
`id` int(11) NOT NULL, | |
`nama` char(1) DEFAULT NULL | |
) ENGINE=InnoDB DEFAULT CHARSET=latin1; | |
-- | |
-- Dumping data for table `kota` | |
-- | |
INSERT INTO `kota` (`id`, `nama`) VALUES | |
(1, 'A'), | |
(2, 'B'), | |
(3, 'C'), | |
(4, 'D'), | |
(5, 'E'), | |
(6, 'F'); | |
-- | |
-- Indexes for dumped tables | |
-- | |
-- | |
-- Indexes for table `jalan` | |
-- | |
ALTER TABLE `jalan` | |
ADD KEY `kota_asal` (`kota_asal`), | |
ADD KEY `kota_tujuan` (`kota_tujuan`); | |
-- | |
-- Indexes for table `kota` | |
-- | |
ALTER TABLE `kota` | |
ADD PRIMARY KEY (`id`); | |
-- | |
-- Constraints for dumped tables | |
-- | |
-- | |
-- Constraints for table `jalan` | |
-- | |
ALTER TABLE `jalan` | |
ADD CONSTRAINT `jalan_ibfk_1` FOREIGN KEY (`kota_asal`) REFERENCES `kota` (`id`), | |
ADD CONSTRAINT `jalan_ibfk_2` FOREIGN KEY (`kota_tujuan`) REFERENCES `kota` (`id`); | |
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; | |
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; | |
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment