Download presentation
Presentation is loading. Please wait.
Published byMerry Russell Modified over 9 years ago
1
Database Fred Durao fred@cs.aau.dk
2
What is a database? A database is any organized collection of data. Some examples of databases you may encounter in your daily life are: a telephone book T.V. Guide airline reservation system papers in your filing cabinet files on your computer hard drive.
3
Why do we need a database? Keep records of our: Clients Staff Volunteers To keep a record of activities and interventions; Keep sales records; Develop reports; Perform research Longitudinal tracking
4
Database management system (DBMS) Software Programs which capable to: store, modify delete ask questions (or queries) about the data stored in the database and produce reports summarizing selected contents. Examples: MS/Access, FileMaker, Lotus Notes, Oracle, SQL Server and MySQL
5
Tables comprise the fundamental building blocks of any database. If you're familiar with spreadsheets, you'll find database tables extremely similar. The table above contains the employee information for our organization -- characteristics like name, date of birth and title. Fundamental building blocks
6
- A relational database is a collection of tables of data, each of which has one special column that stores the primary keys of the table -The rows are the input values for each column, sometimes called entities; - Usually tables contain PRIMARY KEY, which uniquely identify each row in a table. Relational Databases CPRNAMEAGE 1710813015 FRED90 1410481015 THOMAS34 0545413015 ULLA34 TABLE TEACHER CPR is the primary key of table teacher
7
CPRNAMEAGE 1710813015 FRED90 1410481015 THOMAS34 0545413015 ULLA34 TABLE TEACHER COURSE IDCOURSE_NAMECPR 111 WEB DESIGN 1710813015 222 SPANISH 1410481015 333 ENGLISH 0545413015 TABLE COURSE CPR is the COLUMN/FIELD which relates both tables Why Relational Databases?
8
MySql – A OpenSource Database http://www.mysql.com/ A relational database management system (RDBMS) that runs as a server providing multi-user access to a number of databases. MySQL is a popular choice of database for use in web applications. PHP based application, for instance can access MySQL to maintain data. MySQL provides a User Interface Application called MySQL Workbench. Users can visualize and manipulate data though MySQL Workbench. Starting MySQL Workbench in your Windows Machine: START -> Programs -> MySQL -> MySQL Workbench
9
MySql Workbench (1) Click to open a connection (2) Enter your credentials
10
-A standard language to create, query, and modify relational databases -More like structured English than a programming language -We will cover only six basic commands: -CREATE TABLE, - SELECT, - INSERT, - UPDATE, - DELETE, and -DROP SQL - Structured Query Language
11
- To create a database - General form: CREATE DATABASE database_name EX: CREATE DATABASE web; Hint: IF working on the same database use sql command: Use database_name EX: USE WEB; The CREATE DATABASE Command
12
- To create tables in the database - General form: CREATE TABLE table_name ( column_name 1 data_type constraints ) EX: CREATE TABLE `teacher` ( `cpr` INT NOT NULL PRIMARY KEY, `name` VARCHAR(45), `age` INT ); The CREATE TABLE Command
13
- Used to insert data into the table - Three clauses: SELECT, FROM, and WHERE - General form: INSERT INTO table name (column names ) VALUES (values) - The correspondence between column names and values is positional EX: INSERT INTO TEACHER(CPR,NAME,AGE)VALUES(1710718736, 'JOHN', 17); INSERT INTO TEACHER(CPR,NAME,AGE)VALUES(1710811981, 'FRED', 24); INSERT INTO TEACHER(CPR,NAME,AGE)VALUES(1230718736, 'ULLA', 35); The INSERT Command
14
- Used to specify queries - Three clauses: SELECT, FROM, and WHERE - General form: SELECT column names FROM table name WHERE condition Ex: SELECT name FROM TEACHER; Ex: SELECT name FROM TEACHER WHERE age > 20; The SELECT Command
15
- To change/update/modify one or more values of a row in a table - General form: UPDATE table_name SET col_name 1 = value 1 WHERE col_name = value Ex: UPDATE TEACHER SET AGE=23 where CPR = 1230718736; The UPDATE Command
16
- To delete one or more values of a row in a table - General form: DELETE FROM table name where condition - The WHERE clause could specify more than one row of the table EX: DELETE FROM TEACHER WHERE NAME = 'FRED'; The DELETE Command
17
-To drop a table in the database - General form: DROP TABLE table_name EX: DROP TABLE TEACHER The DROP TABLE Command
18
- To drop a existing database - General form: DROP database_name EX: DROP DATABASE WEB; The DROP DATABASE Command
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.