0% found this document useful (0 votes)
45 views

SQL - Lesson 1

A database is any collection of related information that is organized and stored electronically or otherwise. Databases are managed using database management systems that allow users to create, read, update and delete data from the database. There are two main types of databases - relational databases that use tables and relationships to organize data, and non-relational databases that use other data structures like document or key-value pairs.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views

SQL - Lesson 1

A database is any collection of related information that is organized and stored electronically or otherwise. Databases are managed using database management systems that allow users to create, read, update and delete data from the database. There are two main types of databases - relational databases that use tables and relationships to organize data, and non-relational databases that use other data structures like document or key-value pairs.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 22

What is a Database

(DB)?
Any collection of Databases can be
related information stored in different ways
 Phonebook  On paper
 Shopping List  In your mind
 Todo List  On a computer
 Your 5 best friends  This powerpoint
 Facebook’s User base  Comments section
Lazada.com Shopping List
 Keeps track of Products, Reviews,  Keeps track of consumer products
Purchase Orders, Credit Cards, that need to be purchased
Users, Media, etc.
 10-20 pieces of information need
 Trillions of pieces of information to be stored and readily available
need to be stored and readily
available
 Information is for convenience sake
only and not necessary for
 Information is extremely valuable shopping
and critical to Lazada.com
functioning
 Security is not important
 Security is essential, Lazada stores
 Information is stored on a piece of
peoples personal information paper, or even just in someone’s
memory
 Credit card #, Address, phone
 Information is stored on a
computer
Database Management Systems (DBMS)

 A special software program that helps users create and maintain a database
 Makes it easy to manage large amounts of information
 Handles security
 Backups
 Importing/exporting data
 Concurrency
 Interacts with software applications
 Programming languages
 Lazada.com will interact with the DBMS in order to create, read, update, and
delete information
C.R.U.D
CREATE.READ.UPDATE.DELETE
OR
CREATE.RETRIEVE.UPDATE.DELETE
CRUD represents the four (4) main operations
for database management systems
Two Types of Databases

Non-Relational Databases
Relational Databases (SQL) (noSQL/not just SQL)
 Organize data into one or more  Organize data is anything but a
tables traditional table
 Each table has columns and rows  Key value stores
 A unique key identifies each row  Documents (JSON, XML, etc.)
 Graphs
 Flexible tables
Relational Databases (SQL)

Student Table Users Table


*ID # Name Major *Username Password Email
1 Jack Respiratory jsmith22 abc123 …….
2 Gabe Nursing doglover16 iamwho154 …….
3 Jredd Engineering gamelove2 …… ….
4 Luzylle Medicine almanac ….. …..
Relational Databases (SQL)

 Relational Database Management Systems (RDBMS)


 Help users create and maintain a relational database
 mySQL, Oracle, postgreSQL, mariaDB, etc.
 Stuctured Query Language (SQL)
 Standardized language for interacting with RDBMS
 Used to perform C.R.U.D operations as well as other administrative tasks (user
management, security, back up, etc.)
 Used to define tables and structures
 SQL code used on one RDBMS is not always portable to another without
modification
Non-Relational Databases (noSQL/not
just SQL)
 Non-Relational Database Management Systems (NRDBMS)
 Help users create and maintain a non-relational database
 mongoDB, dynamoDB, apache cassandra, firebase, etc.
 Implementation specific
 Any non-relational database falls under this category, so there’s no set language
standard
 Most NRDBMS will implement their own language for performing C.R.U.D. and
administrative operations on the database
Database Queries

Queries are requests made to the database management system for specific
information
As the database’s structure becomes more and more complex, it becomes more
difficult to get the specific pieces of information we want
A google search is a query
Wrap Up

 Database is any collection of related information


 Computers are great for storing databases
 Database Management Systems (DBMS) make it easy to create, maintain, and
secure a database
 DBMS allow you to perform the C.R.U.D. operations and other administrative
tasks
 Two types of Databases, Relational and Non-Relational
 Relational Databases use SQL and store data in tables with rows and columns
 Non-relational databases store data using data structures
 Queries
Tables and Keys
Student
Columns

student_id name major


1 Jack Biology
2 Kate Sociology
3 Claire English Rows
4 Jack Biology
5 Mike Com. Sci
Student

student_id name major


1 Jack Biology
2 Kate Sociology
3 Claire English
4 Jack Biology
5 Mike Com. Sci
User

email Password date_created type


[email protected] abc123 1999-01-02 Admin
[email protected] def456 2001-03-19 Free
[email protected] ghi789 2003-05-02 Free
[email protected] jkl012 2009-02-06 Premium
Employee Surrogate Key

emp_id first_name last_name birth_date sex salary


100 Jack Levinson 1961-05-11 F 110,000
101 Jan Smith 1964-03-23 M 58,000
102 Michael Porter 1972-12-10 M 75,000
103 Josh Martin 1980-09-09 M 63,000
104 Angela Bernard 1978-10-20 F 65,000
Employee Natural Key

emp_sss first_name last_name birth_date sex salary


1123234235 Jack Levinson 1961-05-11 F 110,000
3423532423 Jan Smith 1964-03-23 M 58,000
4435432423 Michael Porter 1972-12-10 M 75,000
4523452232 Josh Martin 1980-09-09 M 63,000
4623452246 Angela Bernard 1978-10-20 F 65,000
Employee Foreign Key

emp_id first_name last_name birth_date sex salary branch_id


100 Jack Levinson 1961-05-11 F 110,000 1
101 Jan Smith 1964-03-23 M 58,000 2
102 Michael Porter 1972-12-10 M 75,000 3
103 Josh Martin 1980-09-09 M 63,000 2
104 Angela Bernard 1978-10-20 F 65,000 3
Employee Foreign Key

emp_id first_name last_name birth_date sex salary branch_id


100 Jack Levinson 1961-05-11 F 110,000 1
101 Jan Smith 1964-03-23 M 58,000 2
102 Michael Porter 1972-12-10 M 75,000 3
103 Josh Martin 1980-09-09 M 63,000 2
104 Angela Bernard 1978-10-20 F 65,000 3

branch_id branch_name mgr_id Foreign Key


2 Tagudin 101
3 San Juan 102
1 San Fernando 103
Surrogate Key
Employee

emp_id first_name last_name birth_date sex salary branch_id super_id


100 Jack Levinson 1961-05-11 F 110,000 1 NULL
101 Jan Smith 1964-03-23 M 58,000 2 100
102 Michael Porter 1972-12-10 M 75,000 3 100
103 Josh Martin 1980-09-09 M 63,000 2 101
104 Angela Bernard 1978-10-20 F 65,000 3 101

branch_id branch_name mgr_id


2 Tagudin 101
3 San Juan 102
1 San Fernando 103
Employee
emp_id first_name last_name birth_date sex salary branch_id super_id
100 Jack Levinson 1961-05-11 F 110,000 1 NULL
101 Jan Smith 1964-03-23 M 58,000 2 100
102 Michael Porter 1972-12-10 M 75,000 3 100
103 Josh Martin 1980-09-09 M 63,000 2 101
104 Angela Bernard 1978-10-20 F 65,000 3 101
branch_id supplier_name supply_type
branch_id branch_name mgr_id
2 Hammer Mill Paper
2 Tagudin 101
2 Uni-ball Writing
3 San Juan 102
3 Patriot Paper Paper
1 San Fernando 103
2 JT Forms Forms
3 Uni-ball Writing
Composite Keys 3 Hammer Mills Paper
3 Stamford Forms

You might also like