Coding Forums

Web development and Application development forums. Seek solution from Experts at Coding-Forum. An Ad-Revenue sharing forum.
Welcome Guest Search | Active Topics | Members | Log In | Register

Coding Forum » Database Forums » MySQL » Someone Please help me add foriegn keys as clearly shown in the related field of this SQL
Someone Please help me add foriegn keys as clearly shown in the related field of this SQL Options
dweddi
Posted: Monday, November 10, 2008 8:56:11 AM
Rank: Newbie
Groups: Member

Joined: 11/10/2008
Posts: 1
Points: 3
Location: Kampala
-- phpMyAdmin SQL Dump
-- version 2.10.1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Nov 10, 2008 at 04:51 PM
-- Server version: 5.0.45
-- PHP Version: 5.2.5

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

--
-- Database: `air_obama`
--

-- --------------------------------------------------------

--
-- Table structure for table `destination`
--

CREATE TABLE `destination` (
`ID` int(3) NOT NULL,
`Dest_ID` int(3) NOT NULL default '0',
`DestName` varchar(15) default NULL,
PRIMARY KEY (`ID`),
UNIQUE KEY `Dest_ID` (`Dest_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `destination`
--


-- --------------------------------------------------------

--
-- Table structure for table `flight`
--

CREATE TABLE `flight` (
`ID` int(3) NOT NULL,
`flight_ID` int(3) default NULL,
`FlightDepTime` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`FlightArrTime` timestamp NOT NULL default '0000-00-00 00:00:00',
`FlightCost` double default NULL,
PRIMARY KEY (`ID`),
UNIQUE KEY `flight_ID` (`flight_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `flight`
--


-- --------------------------------------------------------

--
-- Table structure for table `map_plane_flight_destn`
--

CREATE TABLE `map_plane_flight_destn` (
`ID` int(3) NOT NULL,
`Map_ID` int(3) NOT NULL auto_increment,
`Plane_ID` int(3) NOT NULL,
`Flight_ID` int(3) NOT NULL,
`Dest_ID` int(3) NOT NULL,
PRIMARY KEY (`ID`),
KEY `Map_ID` (`Map_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

--
-- Dumping data for table `map_plane_flight_destn`
--


-- --------------------------------------------------------

--
-- Table structure for table `passenger`
--

CREATE TABLE `passenger` (
`Pas_ID` int(3) default NULL,
`PassName` varchar(20) NOT NULL,
`Sex` char(1) NOT NULL,
`Age` int(2) NOT NULL,
`Flight_ID` int(3) default NULL,
`FlightSeatNo` int(3) default NULL,
`FlightSeateStatus` int(1) default NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `passenger`
--


-- --------------------------------------------------------

--
-- Table structure for table `planes`
--

CREATE TABLE `planes` (
`ID` int(3) NOT NULL,
`plane_ID` int(3) default NULL,
`PlaneName` varchar(15) default NULL,
`TotalSeats` int(3) default NULL,
PRIMARY KEY (`ID`),
UNIQUE KEY `plane_ID` (`plane_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `planes`
--
Sponsor
Posted: Monday, November 10, 2008 8:56:11 AM
Admin
Posted: Tuesday, November 11, 2008 11:39:10 AM
Rank: Administration
Groups: Administration

Joined: 9/14/2008
Posts: 5
Points: 15
Check here for a complete guide on MSQL MySQL Guide

ALTER TABLE map_plane_flight_destn ADD FOREIGN KEY (Dest_ID) REFERENCES destination(Dest_ID);

ALTER TABLE passenger ADD FOREIGN KEY (Flight_ID) REFERENCES flight(Flight_ID);

Users browsing this topic
Guest

Coding Forum » Database Forums » MySQL » Someone Please help me add foriegn keys as clearly shown in the related field of this SQL

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

This page was generated in 0.031 seconds.

Powered by YAF. Theme is derived from Dating forums.
Copyright 2008 Coding Forum