Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Save to My Library
Look up keyword
Like this
1Activity
0 of .
Results for:
No results containing your search query
P. 1
Introduction to SQL

Introduction to SQL

Ratings: (0)|Views: 24 |Likes:
Published by Rifat_mmu

More info:

Published by: Rifat_mmu on May 15, 2008
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less

06/16/2009

pdf

text

original

 
TUTORIAL 1 DATABASE PRACTICE:1. Some Common SQL Data Types:
Data type selection is usually dictated by the nature of the data and by theintended use.
Data TypeFormatDescription
 NumericINTEGER-2 147 483 648+2 147 483 647SMALLINT-32 768 32 767DECIMAL(L,D)DECIMAL(5,2)
123.45
CharacterCHAR(L)CHAR(5)If ‘Ali’, database keeps ‘Ali__’ 2space wasted.VARCHAR(L)VARCHAR(5)If ‘Ali’, database keeps 3 spaceonly.DateDATEYear 0001 9999Month 01 –12Day 01 - 31
2. Creating our own database:
CREATE DATABASE <database name>;CREATE TABLE <table name> (<attribute1 name and attribute1 characteristics,attribute2 name and attribute2 characteristics,attribute3 name and attribute3 characteristics, primary key designation,foreign key designation and foreign key requirements>);Data EntryINSERT INTO <table name> VALUES (attribute 1 value, attribute 2 value, … etc.);
E-R DIAGRAM
 
1 M –CREATE DATABASE COLLEGE; USE COLLEGE;CREATE TABLE PROFESSOR (PROF_ID INTEGER NOT NULL PRIMARY KEY,PROF _LNAME VARCHAR (20),PROF _FNAME VARCHAR (20),PROF _CONTACT VARCHAR (15),PROF _SKILL VARCHAR (20),PROF _PHONE INTEGER,PROF _EMAIL VARCHAR(20));CREATE TABLE STUDENT(STU_ID INTEGER NOT NULL PRIMARY KEY,STU_LNAME VARCHAR (20),STU_FNAME VARCHAR (20),STU_CONTACT VARCHAR(15),STU_SECTION VARCHAR(20),STU_PHONE VARCHAR(10),STU_EMAIL VARCHAR(20),PROF_ID INTEGER NOT NULL,FOREIGN KEY (PROF_ID) REFERENCES PROFESSOR (PROF_ID) ONDELETE CASCADE ON UPDATE CASCADE);INSERT INTO PROFESSOR VALUES (101, ‘Hamid’, ‘Abdul’, ‘Damansara’, 989456,‘Mathematics’, ‘abdul@gmail.com’);INSERT INTO PROFESSOR VALUES (102, ‘Hasan’, ‘Reza’, ‘Bangi’, ‘Java’, 989656,‘reza@gmail.com’);INSERT INTO PROFESSOR VALUES (103, ‘Islam’, ‘Zairul’, ‘Penang’, ‘Database’,989856, ‘zairul@gmail.com’);PROFESSOR STUDENT
MANAG

You're Reading a Free Preview

Download
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->