Cara membuat Database di Sql Server 2008

Cara membuat Database di Sql Server 2008

Cara membangun database dengan menggunakan SQL server 2008:

create database nilaisd

on p[rimary(

name=datanilai,

file name=”D;\namafolder\nilaisd.mdf”,

size=25,

max size =50 mb,

file growth= 5 mb)

log on (

name=lognilai,

filename=”D;\namafolder\nilaisd.mdf”,

size=5,

max size =50 mb,

file growth= 5 mb)

Setelah itu kita bikin new table:

use nilaisd;

create table guru (NIP char (10) primary key not null,Nama_Guru varchar (35),Jabatan varchar (20));

create table siswa (NIS char (10) primary key not null,Nama_Siswa varchar (35),Kelamin char (1), Kode_Kelas char (4));

create table nilai (NIS char (10) primary key not null,Kode_Mapel char (35)not null,NIP char (10)not null, Kode_Kelas char (4)not null, Nilai int);

create table kelas (Kode_Kelas char (10) primary key not null,Kelas varchar (4);

create table mapel (Kode_Mapel char (10) primary key not null,Nama_Mapel varchar (30));

insert into guru values (1993991434,’Darmayanti’,’Wakesek 1′)

insert into guru values (1985123943,’Sugiyanto’,’Kepala Sekolah’)

insert into guru values (1977293845,’Galing’,’Guru Sejarah’)

insert into guru values (1966249593,’Sules’,’Guru Matermatika’)

insert into guru values (1980345985,’Nurul’,’Guru Ipa’)

insert into siswa values (2249194934,’Udiin’,’L’,’111′)

insert into siswa values (2938453992,’Merisya’,’P’,’122′)

insert into siswa values (9293010023,’Iling’,’P’,’111′)

insert into siswa values (9921332403,’Indah’,’P’,’122′)

insert into siswa values (1102994434,’Putri’,’P’,’121 ‘)

insert into nilai values (2938453992,11,1977293845,401,85);

insert into nilai values (1102994434,14,1993991434,402,65);

insert into nilai values (9921332403,21,1980345985,501,70);

insert into nilai values (2249194934,23,1966249593,601,75);

insert into nilai values (9293010023,14,1993991434,501,77);

insert into kelas values (401,’IVa’)

insert into kelas values (402,’IVb’)

insert into kelas values (501,’Va’)

insert into kelas values (601,’VI’)

insert into kelas values (401,’Vb’)

insert into Mapel values (011,’Matematika’)

insert into Mapel values (021,’IPA’)

insert into Mapel values (013,’Bahasa Inggris’)

insert into Mapel values (023,’Sejarah’)

insert into Mapel values (014,’IPS’)

select * from siswa;

select * from guru;

select * from nilai;

select * from mapel;

select * from kelas;

Setelah itu kita bikin new Query:

use nilaisd;

create table guru (nip char (10) primary key not null,nama_guru varchar (35),jabatan varchar (20));

create table siswa (nis char (10) primary key not null,nama_siswa varchar (35),kelamin char (1), kode_kelas char (4));

create table nilai (nis char (10) primary key not null,kode_mapel varchar (35),nip char (10, kode_kelas char (4), nilai int);

create table kelas (kode_kelas char (10) primary key not null,kelas varchar (4));

create table mapel (kode_mapel char (10) primary key not null,nama_mapel varchar (30));

insert into guru values (199919998765,’darmiyanti’,’wakesek 1′)

insert into guru values (199919345345,’sugiyanto’,’kepala sekolah’)

insert into guru values (199912398765,’galing’,’guru sejarah’)

insert into guru values (196569348765,’sules’,’guru matermatika’)

insert into guru values (123919998765,’nurul’,’guru ipa’)

insert into siswa values (12919998765,’bayu’,’L’,’111′)

insert into siswa values (12399198765,’susi’,’P’,’222′)

insert into siswa values (12919998765,’yanti’,’L’,’333′)

insert into siswa values (12399198765,’malin’,’P’,’123′)

insert into siswa values (12919998765,’darmiyanto’,’L’,’444′)

insert into siswa values (12399198765,’darmiyanti’,’P’,’1234′)

select * from siswa;

select * from guru;

select * from nilai;

Sumber : https://mayleneandthesonsofdisaster.us/