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

Lecture 1 Intro To DBMS and Bigquery

The document discusses database schema, which defines the structure of a database including the tables, columns, and relationships between them. It also covers relational database management systems (RDBMS), data warehouses, and Google Cloud Platform (GCP) and BigQuery.

Uploaded by

DevOps CI Mailer
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

Lecture 1 Intro To DBMS and Bigquery

The document discusses database schema, which defines the structure of a database including the tables, columns, and relationships between them. It also covers relational database management systems (RDBMS), data warehouses, and Google Cloud Platform (GCP) and BigQuery.

Uploaded by

DevOps CI Mailer
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

SQL

LECTURE 1
-By Jahanvee Narang
AGENDA
• Schema Design
• RDBMS
• Datawarehouse
• GCP and BigQuery
• Concept of Keys
• Types of Relationships
Presentation title 3

LET’S SET SOME


EXPECTATIONS FIRST
PROBLEM
STATEMENT
Congratulation! You are a data analyst at Reliance
Fresh retailer
Presentation title 5

PROBLEM STATEMENT
• Reliance Fresh has recently decided to open big stores where vendors can directly sell their
produce from their stores.

• All the data is stored in a Database

• Your manager reaches out to you and gives you a DB schema of the backend system that
looks like COMPLEX and asks you to derive all the customer and product-related insights
from this schema?
Presentation title 6

DATABASE SCHEMA
7

SO WHAT ARE YOUR THOUGHTS NOW :


•Where is this data stored? DB?

•What is a DB schema?

•What does each box represent in this diagram?

•What do those lines represent?


Hold your horses
we will cover everything
WHAT IS DBMS? 9

Have you seen a librarian ?


WHAT IS DBMS? 10

A database management system (DBMS) is like a


librarian in a library.

Just as a librarian manages a library's books, a


DBMS manages a computer system's data.

A DBMS is software that helps to organize, store,


and retrieve data efficiently. It provides a way to
access and manage large amounts of information
easily.

Imagine you have a lot of books in your personal


library, and you want to keep track of all of them.
You can write down the title, author, and other
information about each book in a notebook.
However, as your collection grows, it becomes
harder and harder to find the book you're looking
for.
WHAT IS DBMS? 11

A DBMS acts like a sophisticated notebook like


“NOTION DOC” that keeps track of all your
books' information.

It allows you to search and retrieve (data) books by


different criteria such as title, author, genre, and
publication date.

It can also help you organize your books and keep


track of who has borrowed them.
WHAT KIND OF DATA GETS SAVED?
Presentation title 12

•Any interaction you make


with an app, e.g.,
Amazon, searching from
the list of products and
categories, wish-listing a
product, adding to a cart,
and placing an order.

•Whatever web pages we


visit or applications we
use, all of them use some
backend system to collect
all the data.
Now, the tables in which we store
data are also called relations. •All of these backend
systems are connected
→ And thus, this type of DBMS, to Databases that store all
which stores data in a tabular the interactions we make
format, is called Relational DBMS with their app.
or RDBMS.
SUMMARIZE DBMS
• A database management system (DBMS) is software that manages and organizes data
stored in a database.
• A DBMS allows you to store, access, and manipulate this data in a more organized and
efficient way.
• When you use a DBMS, each table represents a specific type of data, such as customers,
orders, or products. Each table contains rows (also known as records) and columns (also
known as fields) that define the structure of the data.
• To access the data in a DBMS, you need to write SQL queries. SQL stands for Structured
Query Language
• For example, if you wanted to extract all the orders from a specific customer, you would
write a SQL query that searches the orders table for all the rows where the customer ID
matches the ID of the customer you're interested in. The DBMS would then return a
result set that contains all the orders that match your criteria.
• The DBMS provides you with a powerful set of tools that allow you to perform these tasks
quickly and efficiently.
FEW POPULAR EXAMPLES OF RDBMS:
Presentation title 14

1. MySQL: MySQL is an open-source RDBMS that is widely used in web applications. It provides high performance,
reliability, and scalability

2. Oracle: Oracle is a commercial RDBMS that is widely used in large enterprises. It provides advanced features such
as high availability, security, and performance tuning

3. Microsoft SQL Server: Microsoft SQL Server is a commercial RDBMS that is widely used in the Microsoft Windows
environment. It provides support for transaction processing, business intelligence, and data analysis

4. PostgreSQL: PostgreSQL is an open-source RDBMS that supports SQL and provides advanced features such as
support for JSON, XML, and geospatial data

5. SQLite: SQLite is an open-source RDBMS that is widely used in embedded systems and mobile applications. It
provides a lightweight, fast, and reliable way to store and manage data
Presentation title 15

DATABASE SCHEMA
Presentation title 16

DATABASE SCHEMA
Each of this
represents
tables
j1
It also includes
datatype of
each column
Slide 16

j1 https://www.w3schools.com/sql/sql_datatypes.asp
jahanvee, 3/16/2023
WHAT IS DATABASE SCHEMA? 17

• A database schema is like a blueprint for a house

• Just as a blueprint provides a plan for a house's construction, a database


schema provides a plan for organizing and storing data in a database
management system (DBMS)

• A database schema defines the structure of a database, including the types


of data that will be stored, the relationships between the data, and the
constraints on the data. It's like a set of rules that govern how data is stored
and retrieved in a DBMS.
WHAT IS DATABASE SCHEMA? 18

• Let’s say you want to build a house.

• You would need a blueprint that specifies the number of rooms, the layout,
the electrical and plumbing systems, and other details. The blueprint would
provide a guide for the construction workers to follow.

• Similarly, in a DBMS, a schema provides a framework for organizing and


managing data. It defines the tables, columns, and relationships between
them, as well as any rules or constraints on the data. The schema ensures
that data is stored in a consistent and organized manner, making it easier to
retrieve and analyze.

• The database schema is the blueprint or structure of the database, which


defines the relationships, constraints, and rules for how the data is
organized and stored in the database. The schema is essential to ensure that
the data is consistent, accurate, and can be easily accessed and understood
by users and applications.
Presentation title 19

Database is collection of inter-related tables


Presentation title 20
Presentation title DATA WAREHOUSE 21

A data warehouse is a large, centralized repository of data that is specifically designed to support business intelligence activities such as
reporting, analysis, and decision-making. Think of it as a massive storage unit for information that has been collected from various sources
within an organization.

Subset of
Datawarehouse to serve
specific business
function or department
LET’S PROCEED
TO GCP
 GCP, or Google Cloud Platform, is a cloud computing platform that
provides a wide range of services for building, deploying, and managing
applications and infrastructure in the cloud

 BigQuery is a cloud-based data warehouse service offered by Google


Cloud Platform.

 It allows users to store and query large amounts of data quickly and
easily using SQL-like queries.

 BigQuery is designed to be scalable, fast, and flexible, making it an ideal


choice for organizations that need to store and analyze large datasets.

22
Presentation title 23

STRUCTURE IN GCP
KEYS
Keys help you identify any data row in a table.

In a real-world application, a table contains millions of


records. Moreover, the records could be duplicated.

Keys in RDBMS ensure that you can uniquely identify a


table record despite these challenges.

Allows you to establish / identify a relationship between


tables

Presentation title TYPES OF RELATION
Primary Key: A primary key uniquely identifies each record in a table. It is
25

typically used as the main identifier for a table


Identify the primary key of each table: Customers table has CustomerID as the
primary key, Orders table has OrderID as the primary key, Products table has
ProductID as the primary key, OrderItemID table has orderID and OrderitemID as
the primary key.
-> {Primary key is unique and cannot be null}

• Foreign Key: A foreign key is fields in one table that refers to the primary
key of another table. It is used to establish a relationship between two
tables and enforce referential integrity.
Identify the foreign key of each table: Orders table has CustomerID as the foreign
key that refers to the Customers table's CustomerID column. OrderDetails table has
OrderID as the foreign key that refers to the Orders table's OrderID column
-> {Foreign key may have name other primary key and can be null and no
restriction to be unique}

• Unique Key: A unique key is like a license plate number. Just as every car
has a unique license plate number, every record in a table with a unique
key has a unique identifier that distinguishes it from all other records.
-> {Unique key can have multiple unique keys and can contain null values}

• Composite Key: A composite key is like a combination lock. Just as a


combination lock requires multiple numbers to be entered in the correct
order to unlock it, a composite key is made up of multiple columns that
together uniquely identify a record.
26

IS AADHAR CARD UNIQUE KEY


OR PRIMARY KEY
• The Aadhaar Card is a unique identification number issued by the Unique Identification Authority of India (UIDAI)
to each resident of India.
• The number is unique to each individual and is used to verify their identity for various purposes such as
government services, bank accounts, and mobile phone connections.
• While the Aadhaar Card number can be used to identify an individual, it is not necessarily the primary identifier
for that individual in all contexts. For example, in a database of bank customers, the primary key might be the
customer account number, while the Aadhaar Card number could be stored as a unique key to ensure that each
customer has a unique identifier in the database.
27

RELATIONSHIPS IN SCHEMA
•One-to-One Relationship:
• In such cases only, a unique row in Table A will be related to one
and only one unique row in Table B.
• Example - marriage between husband and wife.
•One-to-Many Relationship:
• In such cases a single unique row in table A is related to only
multiple rows of Table B.
• Example - company gives employment to employees
•Many-to-One Relationship:
• In such cases many rows in table A are related to only one unique
row of Table B.
• Example - many students can enroll in only one single university.
•Many-to-Many Relationship:
• In such cases many rows in table A are related to many rows of
Table B.
• Example - student course enrollment relationship between
students and Courses offered by university. As many students can
enroll for many courses.
28

RELATIONSHIPS IN SCHEMA

One to many
THANK YOU
- Jahanvee Narang

You might also like