SlideShare a Scribd company logo
Setting Up Postgres
• Setting Up Postgres and a Repository Layer with TypeORM
• Technical requirements
• Setting up our Postgres database
• Understanding object relational mappers by using TypeORM
• Building our repository layer using Postgres and TypeORM
What is data
• Data can come in the form of text, observations, figures,
images, numbers, graphs, or symbols.
• For example, data might include individual prices, weights,
addresses, ages, names, temperatures, dates, or distances.
• Data is a raw form of knowledge and, on its own, doesn't
carry any significance or purpose.
What Is a Database?
• A database is an organized collection of structured
information, or data, typically stored electronically in a
computer system.
• Some real-life examples of databases include student
database, employee database, eCommerce, healthcare,
online banking systems, hotel booking systems, airline
reservation systems.
Module 5 Web Programing Setting Up Postgres.pptx
Module 5 Web Programing Setting Up Postgres.pptx
Types of Databases
• Hierarchical Databases.
• Relational Databases.
• Network Databases.
• Object oriented databases
Types of Databases
• Hierarchical Databases. data model in which the data are
organized into a tree-like structure
A relational database is a type of database that stores and provides access
to data points
• Network Databases. a database model where numerous
records or files can link to multiple owner files
object-oriented database (OOD)
• An object-oriented database (OOD) is a database system
that can work with complex data objects — that is, objects
that mirror those used in object-oriented programming
languages. In object-oriented programming (OOP),
everything is an object.
Module 5 Web Programing Setting Up Postgres.pptx
What Is a Database Management
System?
• Database Management Systems (DBMS) are software
systems used to store, retrieve, and run queries on data.
• A DBMS serves as an interface between an end-user and a
database, allowing users to create, read, update, and delete
data in the database.
• Eg. MySql, Oracle, PostgreSQL, Access, MongoDB
SQL
• What is SQL?
• SQL stands for Structured Query Language
• SQL lets you access and manipulate databases
What Can SQL do?
• SQL can execute queries against a database
• SQL can retrieve data from a database
• SQL can insert records in a database
• SQL can update records in a database
• SQL can delete records from a database
• SQL can create new databases
• SQL can create new tables in a database
What is PostgreSQL and why it is used?
• It is a highly stable database management system, backed
by more than 20 years of community development which
has contributed to its high levels of resilience, integrity, and
correctness.
The minimum hardware required to install and run
PostgreSQL is:
• 1 GHz processor.
• 2 GB of RAM.
• 512 MB of HDD.
Who uses PostgreSQL?
Top Companies using PostgreSQL
Company
Name
Website Revenue
Netflix
www.netflix.co
m
$24.9 Billion
Uber auth.uber.com $14.6 Billion
Instacart
www.instacart.c
om
$1.8 Billion
LaunchDarkly
launchdarkly.co
m
$57 Million
Benefits of PostgreSQL
• In other words, it offers atomicity, consistency, isolation and durability
features. PostgreSQL's advanced features include stored procedures, triggers,
user-defined functions, transactions and replication.
• PostgreSQL provides enterprise-grade scalability performance, availability and
functionality. Thus, you can deploy PostgreSQL in a distributed architecture,
which can handle large volumes of data.
• Another important feature of PostgreSQL is that it’s open source, which makes
it an affordable solution for businesses to keep costs low.
• PostgreSQL has an excellent track record of reliability and data security.
• It’s been used in production by customers for decades and is trusted by many
organizations and businesses worldwide.
How to setup the PostgreSQL?
1.Download the installer from the official PostgreSQL website:
https://www.postgresql.org/download/windows/
2.Run the installer and follow the instructions.
3.Start the PostgreSQL Service:
4.Windows: PostgreSQL service should start automatically after
installation.
5.Access PostgreSQL Shell:
6.Windows: Open the SQL Shell (psql) from the PostgreSQL folder in
the Start menu.
7.Change Password for the PostgreSQL User:
8. Windows: Open the SQL Shell (psql).
9. CREATE DATABASE your_database;
10. Switch to the New Database:
11. Create a User for the Database:
12. CREATE USER your_user WITH PASSWORD 'your_password';
13. GRANT ALL PRIVILEGES ON DATABASE your_database TO your_user;
14. Exit the PostgreSQL ShellConnect to PostgreSQL:
15. You can now connect to PostgreSQL using a database client or your
preferred programming language.For example, using the psql command-
line client:
Class
• A class is a template for creating objects in program.
• Example: Car.
Object
• The object is an instance of a class.
• Example: Jaguar, BMW, Tesla, etc.
Module 5 Web Programing Setting Up Postgres.pptx
Object Relational Mapper (ORM)
• ORM stands for Object-Relational Mapping. It is a
programming technique that allows you to interact with a
relational database using an object-oriented programming
language.
• The main purpose of an ORM is to bridge the gap between
the relational model of a database and the object-oriented
model of a programming language. With an ORM, you can
interact with the database using objects and their methods,
rather than writing raw SQL queries.
TypeScript is an open-source programming language developed by Microsoft.
TypeScript offers numerous benefits for developers
• Improved Developer Experience:
• Enhanced Code Quality:
• Large and complex web applications:
• API development:
• Reduced runtime errors:
• Improved performance:
• TypeORM is an Object-Relational Mapping (ORM) library for
TypeScript
• It enables developers to interact with relational databases
using TypeScript
• TypeORM supports a variety of database management
systems, including PostgreSQL, MySQL, MariaDB, SQLite,
and Microsoft SQL Server.
Building our repository layer using
Postgres and TypeORM
• Building a repository layer using PostgreSQL and TypeORM
involves setting up a database, defining entities, creating a
repository, and integrating TypeORM into your project.
• Below is a step-by-step guide using Node.js and TypeScript,
assuming you have Node.js and npm installed.
Step 1: Project Setup
• Create a new project and initialize it with npm:
Step 2: TypeScript Configuration
• Create a tsconfig.json file in the root directory:
Step 3: PostgreSQL Configuration
• Create a PostgreSQL database and note down the connection details
(host, username, password, database name).
Step 4: TypeORM Configuration
• Create an ormconfig.json file in the root directory:
• Replace "your_username", "your_password", and "your_database" with your
PostgreSQL credentials.
Step 5: Create Entities
• Create a src/entities/User.ts file:
Step 6: Create Repository
• Create a src/repositories/UserRepository.ts file:
Step 7: Create an Express App
• Create a src/index.ts file:
Step 8: Run the Application
• Compile TypeScript and start the application:
Module 5 Web Programing Setting Up Postgres.pptx

More Related Content

Similar to Module 5 Web Programing Setting Up Postgres.pptx (20)

PDF
NoSQL on ACID - Meet Unstructured Postgres
EDB
 
PDF
Bn 1016 demo postgre sql-online-training
conline training
 
PDF
PostgreSQL Server Programming 2nd Edition Usama Dar
obdlioubysz
 
ODP
Introduction to PostgreSQL
Jim Mlodgenski
 
PDF
Postgres database Ibrahem Batta
Ibrahem Batta
 
PDF
PostgreSQL Server Programming 2nd Edition Usama Dar
bhaveeranirh
 
PDF
PostgreSQL Server Programming Second Edition Usama Dar Hannu Krosing Jim Mlod...
trddarvai
 
PDF
0292-introduction-postgresql.pdf
Mustafa Keskin
 
PPTX
Intro_to_fswad_ppt_by_abhay (1).pptx
dipen55
 
PPTX
PostgreSQL - Object Relational Database
Mubashar Iqbal
 
PDF
Beyond Postgres: Interesting Projects, Tools and forks
Sameer Kumar
 
PDF
PostgreSQL, your NoSQL database
Reuven Lerner
 
PDF
Postgres NoSQL - Delivering Apps Faster
EDB
 
PPT
Postgres for the Future
EDB
 
PDF
Postgresql quick guide
Ashoka Vanjare
 
PDF
Get PostgreSQL Server Programming - Second Edition Dar free all chapters
kapuilakna
 
PDF
Whats wrong with postgres | PGConf EU 2019 | Craig Kerstiens
Citus Data
 
PDF
Get PostgreSQL Server Programming - Second Edition Dar free all chapters
raiyaalaiaya
 
PDF
Oracle to Postgres Migration - part 1
PgTraining
 
PDF
PostgreSQL Prologue
Md. Golam Hossain
 
NoSQL on ACID - Meet Unstructured Postgres
EDB
 
Bn 1016 demo postgre sql-online-training
conline training
 
PostgreSQL Server Programming 2nd Edition Usama Dar
obdlioubysz
 
Introduction to PostgreSQL
Jim Mlodgenski
 
Postgres database Ibrahem Batta
Ibrahem Batta
 
PostgreSQL Server Programming 2nd Edition Usama Dar
bhaveeranirh
 
PostgreSQL Server Programming Second Edition Usama Dar Hannu Krosing Jim Mlod...
trddarvai
 
0292-introduction-postgresql.pdf
Mustafa Keskin
 
Intro_to_fswad_ppt_by_abhay (1).pptx
dipen55
 
PostgreSQL - Object Relational Database
Mubashar Iqbal
 
Beyond Postgres: Interesting Projects, Tools and forks
Sameer Kumar
 
PostgreSQL, your NoSQL database
Reuven Lerner
 
Postgres NoSQL - Delivering Apps Faster
EDB
 
Postgres for the Future
EDB
 
Postgresql quick guide
Ashoka Vanjare
 
Get PostgreSQL Server Programming - Second Edition Dar free all chapters
kapuilakna
 
Whats wrong with postgres | PGConf EU 2019 | Craig Kerstiens
Citus Data
 
Get PostgreSQL Server Programming - Second Edition Dar free all chapters
raiyaalaiaya
 
Oracle to Postgres Migration - part 1
PgTraining
 
PostgreSQL Prologue
Md. Golam Hossain
 

More from earningmoney9595 (7)

PPTX
kddprocess-[1].pptx DAta Mining Seminar KDD process
earningmoney9595
 
PPTX
Module_3_Codes and Arithmetic operation.pptx
earningmoney9595
 
PPTX
module-4_sent to students computer organization.pptx
earningmoney9595
 
PPTX
Module 1 Computer Organization (2).pptx
earningmoney9595
 
PPTX
Module 3 Computer Organization Data Hazards.pptx
earningmoney9595
 
PDF
Python_Programming_PPT Basics of python programming language
earningmoney9595
 
PPTX
Powerpoint Presentation on KARNATAKA'S CULTURE
earningmoney9595
 
kddprocess-[1].pptx DAta Mining Seminar KDD process
earningmoney9595
 
Module_3_Codes and Arithmetic operation.pptx
earningmoney9595
 
module-4_sent to students computer organization.pptx
earningmoney9595
 
Module 1 Computer Organization (2).pptx
earningmoney9595
 
Module 3 Computer Organization Data Hazards.pptx
earningmoney9595
 
Python_Programming_PPT Basics of python programming language
earningmoney9595
 
Powerpoint Presentation on KARNATAKA'S CULTURE
earningmoney9595
 
Ad

Recently uploaded (20)

PDF
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
PPTX
How to Configure Re-Ordering From Portal in Odoo 18 Website
Celine George
 
PPTX
PPT-Q1-WEEK-3-SCIENCE-ERevised Matatag Grade 3.pptx
reijhongidayawan02
 
PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
PPTX
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
PDF
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
PDF
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
PDF
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
PDF
Horarios de distribución de agua en julio
pegazohn1978
 
PPTX
Quarter 1_PPT_PE & HEALTH 8_WEEK 3-4.pptx
ronajadolpnhs
 
PDF
Geographical Diversity of India 100 Mcq.pdf/ 7th class new ncert /Social/Samy...
Sandeep Swamy
 
PDF
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
PPTX
How to Handle Salesperson Commision in Odoo 18 Sales
Celine George
 
PDF
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
PDF
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
PDF
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
PPTX
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
PPTX
Neurodivergent Friendly Schools - Slides from training session
Pooky Knightsmith
 
PPTX
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
PPTX
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
How to Configure Re-Ordering From Portal in Odoo 18 Website
Celine George
 
PPT-Q1-WEEK-3-SCIENCE-ERevised Matatag Grade 3.pptx
reijhongidayawan02
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
Horarios de distribución de agua en julio
pegazohn1978
 
Quarter 1_PPT_PE & HEALTH 8_WEEK 3-4.pptx
ronajadolpnhs
 
Geographical Diversity of India 100 Mcq.pdf/ 7th class new ncert /Social/Samy...
Sandeep Swamy
 
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
How to Handle Salesperson Commision in Odoo 18 Sales
Celine George
 
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
Neurodivergent Friendly Schools - Slides from training session
Pooky Knightsmith
 
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
Ad

Module 5 Web Programing Setting Up Postgres.pptx

  • 2. • Setting Up Postgres and a Repository Layer with TypeORM • Technical requirements • Setting up our Postgres database • Understanding object relational mappers by using TypeORM • Building our repository layer using Postgres and TypeORM
  • 3. What is data • Data can come in the form of text, observations, figures, images, numbers, graphs, or symbols. • For example, data might include individual prices, weights, addresses, ages, names, temperatures, dates, or distances. • Data is a raw form of knowledge and, on its own, doesn't carry any significance or purpose.
  • 4. What Is a Database? • A database is an organized collection of structured information, or data, typically stored electronically in a computer system. • Some real-life examples of databases include student database, employee database, eCommerce, healthcare, online banking systems, hotel booking systems, airline reservation systems.
  • 7. Types of Databases • Hierarchical Databases. • Relational Databases. • Network Databases. • Object oriented databases
  • 8. Types of Databases • Hierarchical Databases. data model in which the data are organized into a tree-like structure
  • 9. A relational database is a type of database that stores and provides access to data points
  • 10. • Network Databases. a database model where numerous records or files can link to multiple owner files
  • 11. object-oriented database (OOD) • An object-oriented database (OOD) is a database system that can work with complex data objects — that is, objects that mirror those used in object-oriented programming languages. In object-oriented programming (OOP), everything is an object.
  • 13. What Is a Database Management System? • Database Management Systems (DBMS) are software systems used to store, retrieve, and run queries on data. • A DBMS serves as an interface between an end-user and a database, allowing users to create, read, update, and delete data in the database. • Eg. MySql, Oracle, PostgreSQL, Access, MongoDB
  • 14. SQL • What is SQL? • SQL stands for Structured Query Language • SQL lets you access and manipulate databases
  • 15. What Can SQL do? • SQL can execute queries against a database • SQL can retrieve data from a database • SQL can insert records in a database • SQL can update records in a database • SQL can delete records from a database • SQL can create new databases • SQL can create new tables in a database
  • 16. What is PostgreSQL and why it is used? • It is a highly stable database management system, backed by more than 20 years of community development which has contributed to its high levels of resilience, integrity, and correctness.
  • 17. The minimum hardware required to install and run PostgreSQL is: • 1 GHz processor. • 2 GB of RAM. • 512 MB of HDD.
  • 18. Who uses PostgreSQL? Top Companies using PostgreSQL Company Name Website Revenue Netflix www.netflix.co m $24.9 Billion Uber auth.uber.com $14.6 Billion Instacart www.instacart.c om $1.8 Billion LaunchDarkly launchdarkly.co m $57 Million
  • 19. Benefits of PostgreSQL • In other words, it offers atomicity, consistency, isolation and durability features. PostgreSQL's advanced features include stored procedures, triggers, user-defined functions, transactions and replication. • PostgreSQL provides enterprise-grade scalability performance, availability and functionality. Thus, you can deploy PostgreSQL in a distributed architecture, which can handle large volumes of data. • Another important feature of PostgreSQL is that it’s open source, which makes it an affordable solution for businesses to keep costs low. • PostgreSQL has an excellent track record of reliability and data security. • It’s been used in production by customers for decades and is trusted by many organizations and businesses worldwide.
  • 20. How to setup the PostgreSQL? 1.Download the installer from the official PostgreSQL website: https://www.postgresql.org/download/windows/ 2.Run the installer and follow the instructions. 3.Start the PostgreSQL Service: 4.Windows: PostgreSQL service should start automatically after installation. 5.Access PostgreSQL Shell: 6.Windows: Open the SQL Shell (psql) from the PostgreSQL folder in the Start menu. 7.Change Password for the PostgreSQL User:
  • 21. 8. Windows: Open the SQL Shell (psql). 9. CREATE DATABASE your_database; 10. Switch to the New Database: 11. Create a User for the Database: 12. CREATE USER your_user WITH PASSWORD 'your_password'; 13. GRANT ALL PRIVILEGES ON DATABASE your_database TO your_user; 14. Exit the PostgreSQL ShellConnect to PostgreSQL: 15. You can now connect to PostgreSQL using a database client or your preferred programming language.For example, using the psql command- line client:
  • 22. Class • A class is a template for creating objects in program. • Example: Car. Object • The object is an instance of a class. • Example: Jaguar, BMW, Tesla, etc.
  • 24. Object Relational Mapper (ORM) • ORM stands for Object-Relational Mapping. It is a programming technique that allows you to interact with a relational database using an object-oriented programming language. • The main purpose of an ORM is to bridge the gap between the relational model of a database and the object-oriented model of a programming language. With an ORM, you can interact with the database using objects and their methods, rather than writing raw SQL queries.
  • 25. TypeScript is an open-source programming language developed by Microsoft. TypeScript offers numerous benefits for developers • Improved Developer Experience: • Enhanced Code Quality: • Large and complex web applications: • API development: • Reduced runtime errors: • Improved performance:
  • 26. • TypeORM is an Object-Relational Mapping (ORM) library for TypeScript • It enables developers to interact with relational databases using TypeScript • TypeORM supports a variety of database management systems, including PostgreSQL, MySQL, MariaDB, SQLite, and Microsoft SQL Server.
  • 27. Building our repository layer using Postgres and TypeORM • Building a repository layer using PostgreSQL and TypeORM involves setting up a database, defining entities, creating a repository, and integrating TypeORM into your project. • Below is a step-by-step guide using Node.js and TypeScript, assuming you have Node.js and npm installed.
  • 28. Step 1: Project Setup • Create a new project and initialize it with npm: Step 2: TypeScript Configuration • Create a tsconfig.json file in the root directory: Step 3: PostgreSQL Configuration • Create a PostgreSQL database and note down the connection details (host, username, password, database name). Step 4: TypeORM Configuration • Create an ormconfig.json file in the root directory:
  • 29. • Replace "your_username", "your_password", and "your_database" with your PostgreSQL credentials. Step 5: Create Entities • Create a src/entities/User.ts file: Step 6: Create Repository • Create a src/repositories/UserRepository.ts file: Step 7: Create an Express App • Create a src/index.ts file: Step 8: Run the Application • Compile TypeScript and start the application: