0% found this document useful (0 votes)
62 views

SQL DB

This document defines the table structures for a database that stores information about courses, attendees, instructors, facilities, and attendance. Fourteen tables are created to store data about administrators, members, branches, facilities, courses, instructors, enrollments, course dates/times, and locations. Primary and foreign keys are set to link the tables together and auto-increment is enabled for identification fields.

Uploaded by

viola genevieve
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)
62 views

SQL DB

This document defines the table structures for a database that stores information about courses, attendees, instructors, facilities, and attendance. Fourteen tables are created to store data about administrators, members, branches, facilities, courses, instructors, enrollments, course dates/times, and locations. Primary and foreign keys are set to link the tables together and auto-increment is enabled for identification fields.

Uploaded by

viola genevieve
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/ 5

-- Database: `skk`

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

-- Table structure for table administrator

CREATE TABLE administrator (

noBadan int(6) NOT NULL,

username varchar(50) NOT NULL,

pwd varchar(50) NOT NULL,

ADD PRIMARY KEY (username),

ADD FOREIGN KEY noBadan REFERENCES anggota_pengawai(noBadan)

);

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

-- Table structure for table anggota_pengawai

CREATE TABLE anggota_pengawai (

pangkat_kod varchar(2) NOT NULL,

noBadan int(6) NOT NULL,

pangkat_pos varchar(10),

nama varchar(100) NOT NULL,

ADD PRIMARY KEY (noBadan)

);

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

-- Table structure for table cawangan_ap

CREATE TABLE cawangan_ap (

noBadan int(6) NOT NULL,

cawangan varchar(50),

unit varchar(50),

ADD UNIQUE KEY noBadan (noBadan);

);

-- --------------------------------------------------------
-- Table structure for table `fasiliti`

CREATE TABLE fasiliti (

idFasiliti varchar(2) NOT NULL,

namaFasiliti varchar(100) NOT NULL,

ADD PRIMARY KEY (idFasiliti)

);

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

-- Table structure for table `kehadiran`

CREATE TABLE kehadiran (

pkey int(11) NOT NULL,

keyKehadiran int(11) NOT NULL,

tarikh date,

masa_masuk time,

komenTH text,

kehadiran int(1),

ADD PRIMARY KEY (pkey),

ADD FOREIGN KEY keyKehadiran REFERENCES senarai_kursus(pkey)

);

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

-- Table structure for table `kursus`

CREATE TABLE kursus (

idKursus int(5) NOT NULL,

namaKursus varchar(100) NOT NULL,

noSiri varchar(2),

tahun year(4),

modifiedByvarchar(50),

ADD PRIMARY KEY (idKursus),

ADD FOREIGN KEY modifiedBy REFERENCES administrator(username)

);
-- --------------------------------------------------------

-- Table structure for table `pengajar`

CREATE TABLE pengajar (

noBadan int(6) NOT NULL,

idKursus int(5) NOT NULL,

pkey int(11) NOT NULL,

ADD PRIMARY KEY (pkey),

ADD KEY noBadan REFERENCES anggota_pengawai(noBadan),

ADD KEY idKursus REFERENCES kursus(idKursus);

);

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

-- Table structure for table `senarai_kursus`

CREATE TABLE senarai_kursus (

pkey int(11) NOT NULL,

noBadan int(6) NOT NULL,

idKursus int(5) NOT NULL,

ADD PRIMARY KEY (pkey),

ADD FOERIGN KEY idKursus REFERENCES kursus(idKursus),

ADD FOREIGN KEY noBadan REFERENCES anggota_pengawai(noBadan)

);

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

-- Table structure for table `tarikh_kursus`

CREATE TABLE tarikh_kursus (

idKursus int(5) NOT NULL,

tarikh_mula date,

tarikh_akhir date,

masa_mula time,

masa_akhir time,

ADD UNIQUE KEY idKursus (idKursus)


);

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

-- Table structure for table `tempat_kursus`

CREATE TABLE tempat_kursus (

idKursus int(5) NOT NULL,

idFasiliti varchar(2) NOT NULL,

pkey int(11) NOT NULL

ADD PRIMARY KEY (pkey),

ADD FOREIGN KEY idFasiliti REFERENCES fasiliti(idFasiliti),

ADD KEY idKursus REFERENCES kursus(idKursus)

);

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

-- AUTO_INCREMENT for table `kehadiran`

ALTER TABLE kehadiran

MODIFY pkey int(11) NOT NULL AUTO_INCREMENT;

-- AUTO_INCREMENT for table `kursus`

ALTER TABLE kursus

MODIFY idKursus int(5) NOT NULL AUTO_INCREMENT;

-- AUTO_INCREMENT for table `pengajar`

ALTER TABLE pengajar

MODIFY pkey int(11) NOT NULL AUTO_INCREMENT;

-- AUTO_INCREMENT for table `senarai_kursus`

ALTER TABLE senarai_kursus

MODIFY pkey int(11) NOT NULL AUTO_INCREMENT;

-- AUTO_INCREMENT for table `tempat_kursus`


ALTER TABLE tempat_kursus

MODIFY pkey int(11) NOT NULL AUTO_INCREMENT;

You might also like