You are on page 1of 2

Database (Relational)

Data is stored in tables


COMP233B Internet u
– Columns are attributes or fields
Applications – Rows are different data items

Lecture 33: Database & SQL Name Address PhoneNumber


Bill 999 Abc Rd. 5559876
Mary 27a Xyx St. 8765432
John 12 Ijk Rd. 9812345

Database (Relational) MySQL


u Data is stored in tables u Client / Server DBMS’s
– Columns are attributes or fields – MySQL
– Rows are different data items – SQL Server
– DB2, Oracle, Ingres,
Ingres, Postgres
u A database is a collection of tables u MySQL is on its own machine (mysql
(mysql))
– Manages many databases
u A dbms is a program that manages – One has/will be created for each of us
databases – Mine is ‘coms0108’, password ‘coms0108’
– Web site is www.mysql.com

Using MySQL Using MySQL


u Interactively – using mysql program u Will accept SQL commands
Attaching and authentication – Followed by semicolon
mysql -h sql.scms.waikato.ac.nz – Allows multi-
multi-line commands
-u coms0108 -p u Some special commands
and enter password when asked – help;
(passwords – last 8 digits of barcode) – show tables;
– describe tablename;
tablename;
u From PHP

1
SQL An Example
u create table phonebook
u Structured Query Language (name char(20), number int);
– create table tablename (field int, field char(20))
– drop table tablename u show table phonebook;
– select field, field from tablename where … u describe phonebook;
– delete from tablename where … u insert into phonebook (name, number)
– insert into tablename (field, ) values (1, 2)
values (’Bill’, 4408);
– update tablename set f=1, f2=3 where …
u insert into phonebook (name, number)
values (’Geoff’, 4405);

You might also like