rizaarifudin[dot]com

Berbagi ilmu, pengalaman, tips dan trik, software

You are here: » SQL untuk dbzoo

SQL untuk dbzoo

Berikut ini merupakan sintax SQL untuk membuat database dbzoo.

CREATE DATABASE dbzoo;

CREATE TABLE TheEmployees (
Ename varchar(20) NOT NULL,
address varchar(25) default NULL,
PRIMARY KEY  (Ename));

CREATE TABLE TheSupervisors (
pathNum smallint(6) NOT NULL,
Ename varchar(20) default NULL,
PRIMARY KEY  (pathNum),
FOREIGN KEY  (Ename) REFERENCES
TheEmployees(Ename));

CREATE TABLE TheCages (
cNum smallint(6) NOT NULL,
pathNum smallint(6) NOT NULL,
function varchar(25) default NULL,
PRIMARY KEY  (cNum),
FOREIGN key (pathNum) REFERENCES
TheSupervisors(pathNum));

CREATE TABLE TheGuards (
cNum smallint(6) NOT NULL,
Ename varchar(20) NOT NULL,
PRIMARY KEY  (cNum,Ename),
FOREIGN KEY (Ename) REFERENCES
TheEmployees(Ename),
FOREIGN KEY (cNum) REFERENCES
TheCages(cNum));

CREATE TABLE TheAnimals (
Aname varchar(20) NOT NULL,
sex varchar(10) default NULL,
type varchar(20) default NULL,
country varchar(20) default NULL,
yearOfBirth int(11) default NULL,
cNum smallint(6) NOT NULL,
PRIMARY KEY  (Aname),
FOREIGN KEY (cNum) REFERENCES
TheCages(cNum));

CREATE TABLE TheDiseases (
Aname varchar(20) NOT NULL,
Dname varchar(25) NOT NULL,
PRIMARY KEY  (Aname,Dname),
foreign key (Aname) REFERENCES
TheAnimals(Aname));

– Download text ada di SQL Untuk dbzoo

– Untuk mengisikan tabel silahkan lihat ke sini

Selamat mencoba

Posted by 0 Responses
 

Free Email Newsletter

Stay Updates with this Blog. Get Free email newsletter updates..

And then confirm your email subcription

   

No Comment to “SQL untuk dbzoo”

  1. No Comment yet. Be the first to comment...
Leave your comment here:

*

Apr
5
2011
 
Archives
Chat
Name:
Email:
For:  
Mail will not be published
(but it's required)