Exercise: Do The Following Exercise Carefully Create Command Used To Create Database and Table
Exercise: Do The Following Exercise Carefully Create Command Used To Create Database and Table
Exercise: Do The Following Exercise Carefully Create Command Used To Create Database and Table
);
Page 1 of 7
University of Gondar Computer Science Department
FUNDAMMETAL Database Systems
Click on database diagram -----yes--------right click on database diagram and click create new diagram
-------- Add the table as you went to create relationship then save
Diagram 1
Page 2 of 7
University of Gondar Computer Science Department
FUNDAMMETAL Database Systems
Insert into course (crsId,crsName,Credithrs,studID,TeachID)
Values (001,'RAD',100,01,111)
Insert into course (crsId,crsName,Credithrs,studID,TeachID)
Values (002,'IT',120,02,222)
Insert into course (crsId,crsName,Credithrs,studID,TeachID)
Values (003,'IQ',45,03,333)
01 Hana kebede F
02 abebe tesema M
03 elsa kassa F
TeachID
crsId crsName Credit hrs studID
The SELECT statement is used to select data from a database; the result is stored in a result table, called the result-
set.
Or
SELECT crsID,crsName,Credithrs,studID,TeachID
FROM course
SELECT studID,studid,TeachID
FROM course
In a table, some of the columns may contain duplicate values. This is not a problem; however, sometimes you will want to
list only the different (distinct) values in a table. The DISTINCT keyword can be used to return only distinct (different)
values.
SELECT crsID,crsName,Credithrs,studID,TeachID
FROM course
where crsID=001
Page 4 of 7
University of Gondar Computer Science Department
FUNDAMMETAL Database Systems
SQL uses single quotes around text values (most database systems will also accept double quotes).Although, numeric
values should not be enclosed in quotes.
The ORDER BY keyword is used to sort the result-set by a specified column. The ORDER BY keyword sorts the records
in ascending order by default. If you want to sort the records in a descending order, you can use the DESC keyword, and
ascending use ASC.
SELECT studid,fname,lname
FROM student
ORDER BY fname desc
The UPDATE Statement The UPDATE statement is used to update existing records in a table. For example to increase
the teacher salary by 4times
UPDATE teacher
SET salary=(salary*4)
Page 5 of 7
University of Gondar Computer Science Department
FUNDAMMETAL Database Systems
Note: Notice the WHERE clause in the UPDATE syntax. The WHERE clause specifies which record or records that
should be updated. If you omit the WHERE clause, all records will be updated! For example to update the salary of Id 222
UPDATE teacher
SET salary=(salary*4)
where teachID=222
Delete the single record For example if you went to delete the data on the students where
student Id 01 you can use
But you cant delete this record b/se the relationship b/n two tables are exit due to
foreign key referencional integrity so to delete the above record first delete the main
chain table record the try again
Where studid=01
to disk ='d:\program.bkf'
To drop the database ,Close all opend database object explorer or query sheet then type
Page 6 of 7
University of Gondar Computer Science Department
FUNDAMMETAL Database Systems
drop table course
Page 7 of 7