DATABASE SYSTEMS
Dr.Amgad Monir
Refreshing
• What is a database ?
• Computers + databases = …..
• What is DBMS ?
• What is C.R.U.D ?
• Types of databases
• Database Queries
• Creating tables
• Inserting data
• Constraints
What is a database ?
Computers + databases
Database Management System (DBMS) ?
Amazon.com database diagram
C.R.U.D
Two types of databases
Relational databases (SQL)
Relational databases (SQL)
NoSQL Database Types
Discussing NoSQL databases is complicated
because there are a variety of types:
•Sorted ordered Column Store
•Optimized for queries over large datasets, and store
columns of data together, instead of rows
•Document databases:
•pair each key with a complex data structure known as a document.
•Key-Value Store :
•are the simplest NoSQL databases. Every single item in the database is stored as an attribute name (or 'key'),
together with its value.
•Graph Databases :
•are used to store information about networks of data, such as social connections.
Non-Relational databases (NoSQL)
Document Database (NoSQL)
Graph Database (NoSQL)
Database Queries
Tables and Keys
Tables and Keys
Tables and Keys
SQL
SQL
Tools
Basic Data Types in SQL
Creating tables
CREATE TABLE student (
student_id INT PRIMARY KEY,
name VARCHAR(40),
major VARCHAR(40)
);
DESCRIBE student;
ALTER TABLE student ADD gpa DECIMAL;
ALTER TABLE student DROP COLUMN gpa;
DROP TABLE student;
Inserting Data
INSERT INTO student VALUES(1, 'Jack', 'Biology');
INSERT INTO student VALUES(2, 'Kate', 'Sociology');
INSERT INTO student(student_id, name) VALUES(3, 'Claire');
INSERT INTO student VALUES(4, 'Jack', 'Biology');
INSERT INTO student VALUES(5, 'Mike', 'Computer Science');
Constraints
CREATE TABLE student (
student_id INT PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(40) NOT NULL,
major VARCHAR(40) DEFAULT 'undecided' );