SlideShare a Scribd company logo
1 of 25
Database BasicsDatabase Basics
By: Muhammad NawazBy: Muhammad Nawaz
What is a databaseWhat is a database
A database is any organized collection ofA database is any organized collection of
data.data. Some examples of databases youSome examples of databases you
may encounter in your daily life are:may encounter in your daily life are:

a telephone booka telephone book

airline reservation systemairline reservation system

motor vehicle registration recordsmotor vehicle registration records

files on your computer hard drivefiles on your computer hard drive

Employment recordsEmployment records
Data vs. information:Data vs. information:
What is the difference?What is the difference?
What is data?What is data?

Raw Facts and Figures.Raw Facts and Figures.
Information science definesInformation science defines
data as unprocesseddata as unprocessed
information.information.
What is information?What is information?

Information is data thatInformation is data that
have been organized andhave been organized and
communicated in acommunicated in a
coherent and meaningfulcoherent and meaningful
manner.manner.

Data is converted intoData is converted into
information, andinformation, and
information is convertedinformation is converted
into knowledge.into knowledge.

Knowledge; informationKnowledge; information
evaluated and organizedevaluated and organized
so that it can be usedso that it can be used
purposefully.purposefully.
Why do we need a database?Why do we need a database?
Keep records of our:Keep records of our:

ClientsClients

StaffStaff
Keep sales records;Keep sales records;
Develop reports;Develop reports;
Perform researchPerform research
What is the ultimate purpose ofWhat is the ultimate purpose of
a database managementa database management
system?system?
DataData InformationInformation KnowledgeKnowledge ActionAction
Is to transformIs to transform
Database management systemsDatabase management systems
(DBMS)(DBMS)
collections of tools used to manage databasescollections of tools used to manage databases
Basic functions performed by all DBMS are:Basic functions performed by all DBMS are:
Create, modify, and delete data structures,Create, modify, and delete data structures,
e.g. tablese.g. tables
Add, modify, and delete dataAdd, modify, and delete data
Retrieve data selectivelyRetrieve data selectively
Generate reports based on dataGenerate reports based on data
Database ModelsDatabase Models
a number of different ways of modeling thea number of different ways of modeling the
database structure: these are known asdatabase structure: these are known as
“database models” (or data models).“database models” (or data models).
The model in most common use today isThe model in most common use today is
thethe relational model, which in layman'srelational model, which in layman's
terms represents allterms represents all information in theinformation in the
form of multiple related tables eachform of multiple related tables each
consisting of rows and columnsconsisting of rows and columns
Databases ComponentsDatabases Components
Related tables/RelationsRelated tables/Relations
FieldsFields
RecordsRecords
TablesTables
A table is a collection of related records. ForA table is a collection of related records. For
example, employee table, product table,example, employee table, product table,
customer, and orders tablescustomer, and orders tables
In a table, records are represented by rows andIn a table, records are represented by rows and
fields are represented as columns.fields are represented as columns.
FieldsFields
An area (within a record) reserved for a specific piece ofAn area (within a record) reserved for a specific piece of
datadata
Examples: customer id, customer name, street address,Examples: customer id, customer name, street address,
city, phone, current balancecity, phone, current balance
defined by:defined by:
Field nameField name
Data typeData type
Field size (Field size (Amount of space reserved for storing dataAmount of space reserved for storing data ))
RecordRecord
A record is the collection of values for allA record is the collection of values for all
the fields belong to one entity: i.e. athe fields belong to one entity: i.e. a
person, product, company, transaction,person, product, company, transaction,
etc.etc.
Key field column(DOB is field)Key field column(DOB is field)
recordrecord Customer No Name DOB
…… …… …….
1234 Bilal 10/10/1990
One-to-OneOne-to-One
One-to-ManyOne-to-Many
Many-to-ManyMany-to-Many
RelationshipsRelationships
RelationshipsRelationships
One-to-Many relationship:One-to-Many relationship: Customer-Order, each order has onlyCustomer-Order, each order has only
one customer, but a customer can make many ordersone customer, but a customer can make many orders
One-to-Many relationships consist of two tables, the "one" table, andOne-to-Many relationships consist of two tables, the "one" table, and
the "many“ tablesthe "many“ tables
CustomerCustomer
OrderOrder
1 m1 m
RelationshipsRelationships
Many-to-Many relationship: Order-Product, an orderMany-to-Many relationship: Order-Product, an order
can contain many products,can contain many products, and a product can be onand a product can be on
many ordersmany orders
A Many-to-Many relationship consists of three tables:A Many-to-Many relationship consists of three tables:
two "one" tables, both in a One-to-Many relationship withtwo "one" tables, both in a One-to-Many relationship with
a third table. The third table is sometimes referred to asa third table. The third table is sometimes referred to as
the lienthe lien
Product OrderProduct Order
m nm n
Key FieldsKey Fields
Primary key:Primary key: A Primary key is a field or a combination of twoA Primary key is a field or a combination of two
or moreor more fields. Thefields. The value in the primary key field for each recordvalue in the primary key field for each record
uniquely identifies that recorduniquely identifies that record
In our previous example, customer number is the Primary key forIn our previous example, customer number is the Primary key for
the Customer table. A customer number identifies one and only onethe Customer table. A customer number identifies one and only one
customer in the Customer tablecustomer in the Customer table
Foreign key: When a "one" table's primary key field is added toForeign key: When a "one" table's primary key field is added to
aa related "many" table in order to create the common field whichrelated "many" table in order to create the common field which
relates the two tables, it is called a foreign key in the "many" table.relates the two tables, it is called a foreign key in the "many" table.
the primary key (customer number) from the Customer table ("one"the primary key (customer number) from the Customer table ("one"
table) is a foreign key in the Orders table ("many" table). For thetable) is a foreign key in the Orders table ("many" table). For the
"many" records of the Order table, the foreign key identifies with"many" records of the Order table, the foreign key identifies with
which unique record in the Customer table they are associated.which unique record in the Customer table they are associated.
Data TypesData Types
This will hold between 0 and 255 characters. You have to specifyThis will hold between 0 and 255 characters. You have to specify
the maximum amount of characters that you will be putting herethe maximum amount of characters that you will be putting here
when you create your columnwhen you create your column
This will hold as many characters as you like up to 2 gigabytes ofThis will hold as many characters as you like up to 2 gigabytes of
spacespace
This can hold a value of 0 or 1. It is primarily used for yes/no andThis can hold a value of 0 or 1. It is primarily used for yes/no and
true/false issues. It is also referred to as a Boolean or Yes/Notrue/false issues. It is also referred to as a Boolean or Yes/No
field.field.
This type is used to store decimal numbers. It is primarily used forThis type is used to store decimal numbers. It is primarily used for
mathematical purposesmathematical purposes
This type indicates that you are storing whole numbers here. YouThis type indicates that you are storing whole numbers here. You
can store any whole number between -2147483648 andcan store any whole number between -2147483648 and
21474836482147483648
● CHARCHAR
VARCHARVARCHAR
BITBIT
FLOATFLOAT
INTINT
How Do I Create a Table?How Do I Create a Table?
Using an SQL statement.Using an SQL statement.
CREATE TABLE contacts (CREATE TABLE contacts (
contact_id INT IDENTITY (1, 1) NOT NULL ,contact_id INT IDENTITY (1, 1) NOT NULL ,
first_name CHAR (30) NULL ,first_name CHAR (30) NULL ,
last_name CHAR (50) NULL ,last_name CHAR (50) NULL ,
email VARCHAR (75) NULLemail VARCHAR (75) NULL
););
Designing a Table in a DatabaseDesigning a Table in a Database
Tool? ….Tool? ….
Using Microsoft AccessUsing Microsoft Access
INSERT statementINSERT statement
INSERT INTO contactsINSERT INTO contacts
(first_name, last_name, email)(first_name, last_name, email)
VALUES (‘Bilal',‘Afzal',‘bilal@hotmail.com’);VALUES (‘Bilal',‘Afzal',‘bilal@hotmail.com’);
What is thatWhat is that NULL thing?NULL thing?
NULL is how you tell the DBMS that you have nothing toNULL is how you tell the DBMS that you have nothing to
enter in this columnenter in this column
UPDATE StatementUPDATE Statement
UPDATE contactsUPDATE contacts
SETSET
email = ‘bilal@hotmail.com‘email = ‘bilal@hotmail.com‘
WHEREWHERE
contact_id = 1;contact_id = 1;
SELECT StatementSELECT Statement
SELECT * FROM contacts;SELECT * FROM contacts;
SELECT first_name, emailSELECT first_name, email
FROMFROM
contactscontacts
WHEREWHERE
first_name = ‘Bilal';first_name = ‘Bilal';
DELETE statementDELETE statement
DELETEDELETE
FROM contactsFROM contacts
WHERE contact_id = 3;WHERE contact_id = 3;
Example QueriesExample Queries
AND/OR operatorsAND/OR operators
SELECT * FROM contacts WHERE(first_name=‘Bilal'SELECT * FROM contacts WHERE(first_name=‘Bilal' ANDAND
last_name=‘Afzal')last_name=‘Afzal') OR last_name=‘Ahmed';OR last_name=‘Ahmed';
LIKELIKE
SELECT * FROM contact WHERE last_nameSELECT * FROM contact WHERE last_name LIKE '%al';LIKE '%al';
ORDER BY Clause:ORDER BY Clause:
SELECT * FROM contacts ORDER BY last_nameSELECT * FROM contacts ORDER BY last_name DESC;DESC;
ThanksThanks

More Related Content

What's hot

Cis336 all i labs week 1 to week 7 devry university
Cis336 all i labs week 1 to week 7 devry universityCis336 all i labs week 1 to week 7 devry university
Cis336 all i labs week 1 to week 7 devry university
7Fase1
 
Advance Sqlite3
Advance Sqlite3Advance Sqlite3
Advance Sqlite3
Raghu nath
 
Relational Databases
Relational DatabasesRelational Databases
Relational Databases
Jason Hando
 
Advance sqlite3
Advance sqlite3Advance sqlite3
Advance sqlite3
Raghu nath
 

What's hot (18)

Database design
Database designDatabase design
Database design
 
App B
App BApp B
App B
 
Book HH - SQL MATERIAL
Book   HH - SQL MATERIALBook   HH - SQL MATERIAL
Book HH - SQL MATERIAL
 
Cis336 all i labs week 1 to week 7 devry university
Cis336 all i labs week 1 to week 7 devry universityCis336 all i labs week 1 to week 7 devry university
Cis336 all i labs week 1 to week 7 devry university
 
Advance Sqlite3
Advance Sqlite3Advance Sqlite3
Advance Sqlite3
 
Starting ms access 2010
Starting ms access 2010Starting ms access 2010
Starting ms access 2010
 
Normalization
NormalizationNormalization
Normalization
 
Relational Databases
Relational DatabasesRelational Databases
Relational Databases
 
Normalization Accepted
Normalization AcceptedNormalization Accepted
Normalization Accepted
 
Advance sqlite3
Advance sqlite3Advance sqlite3
Advance sqlite3
 
Sas training institute in marathahalli bangalore
Sas training institute in marathahalli bangaloreSas training institute in marathahalli bangalore
Sas training institute in marathahalli bangalore
 
Database
Database Database
Database
 
Fa 4 cse g35-1 dbms
Fa 4 cse g35-1 dbmsFa 4 cse g35-1 dbms
Fa 4 cse g35-1 dbms
 
Ch1- Introduction to dbms
Ch1- Introduction to dbmsCh1- Introduction to dbms
Ch1- Introduction to dbms
 
It's Not You. It's Your Data Model.
It's Not You. It's Your Data Model.It's Not You. It's Your Data Model.
It's Not You. It's Your Data Model.
 
Microsoft Excel introduction
Microsoft Excel introductionMicrosoft Excel introduction
Microsoft Excel introduction
 
01 Microsoft Access
01 Microsoft Access01 Microsoft Access
01 Microsoft Access
 
A "M"ind Bending Experience. Power Query for Excel and Beyond.
A "M"ind Bending Experience. Power Query for Excel and Beyond.A "M"ind Bending Experience. Power Query for Excel and Beyond.
A "M"ind Bending Experience. Power Query for Excel and Beyond.
 

Viewers also liked (14)

осенние листья
осенние листьяосенние листья
осенние листья
 
Extranet documentos
Extranet documentosExtranet documentos
Extranet documentos
 
Resposta pesquisa mineral
Resposta pesquisa mineralResposta pesquisa mineral
Resposta pesquisa mineral
 
Universidad tecnica de ambato
Universidad tecnica de ambatoUniversidad tecnica de ambato
Universidad tecnica de ambato
 
Dias e dias
Dias e diasDias e dias
Dias e dias
 
Revista Literária Buritizeiros
Revista Literária BuritizeirosRevista Literária Buritizeiros
Revista Literária Buritizeiros
 
Firewall for a small medium business
Firewall for a small medium business Firewall for a small medium business
Firewall for a small medium business
 
треугольник
треугольниктреугольник
треугольник
 
ELEIÇÕES 2012 - ASTORGA : Dorival 11234
ELEIÇÕES 2012 - ASTORGA : Dorival 11234ELEIÇÕES 2012 - ASTORGA : Dorival 11234
ELEIÇÕES 2012 - ASTORGA : Dorival 11234
 
Novo(a) apresentação open document
Novo(a) apresentação open documentNovo(a) apresentação open document
Novo(a) apresentação open document
 
Els drets humans i els seus incompliments 1
Els drets humans i els seus incompliments 1Els drets humans i els seus incompliments 1
Els drets humans i els seus incompliments 1
 
проказы старухи зимы
проказы старухи зимыпроказы старухи зимы
проказы старухи зимы
 
презентация мастер класс
презентация мастер класспрезентация мастер класс
презентация мастер класс
 
Quimica 1º ano - 01
Quimica   1º ano - 01Quimica   1º ano - 01
Quimica 1º ano - 01
 

Similar to Database

Physical elements of data
Physical elements of dataPhysical elements of data
Physical elements of data
Dimara Hakim
 
CS1100 Access Lab 1 Creating and Querying Database.docx
CS1100 Access Lab 1  Creating and Querying Database.docxCS1100 Access Lab 1  Creating and Querying Database.docx
CS1100 Access Lab 1 Creating and Querying Database.docx
faithxdunce63732
 
databases3b
databases3bdatabases3b
databases3b
c.west
 
2 Relational Database Concepts.ppt
2 Relational Database Concepts.ppt2 Relational Database Concepts.ppt
2 Relational Database Concepts.ppt
Souha Bennani
 
Database Tables and Data Types
Database Tables and Data TypesDatabase Tables and Data Types
Database Tables and Data Types
Rushdi Shams
 
Database Fundamentals
Database FundamentalsDatabase Fundamentals
Database Fundamentals
lindy23
 
18 database features
18 database features18 database features
18 database features
Rebecca Jones
 

Similar to Database (20)

Database Concepts and Terminologies
Database Concepts and TerminologiesDatabase Concepts and Terminologies
Database Concepts and Terminologies
 
Physical elements of data
Physical elements of dataPhysical elements of data
Physical elements of data
 
CS1100 Access Lab 1 Creating and Querying Database.docx
CS1100 Access Lab 1  Creating and Querying Database.docxCS1100 Access Lab 1  Creating and Querying Database.docx
CS1100 Access Lab 1 Creating and Querying Database.docx
 
Database Management System
Database Management SystemDatabase Management System
Database Management System
 
Introduction to database
Introduction to databaseIntroduction to database
Introduction to database
 
Databasell
DatabasellDatabasell
Databasell
 
Access 2010
Access 2010Access 2010
Access 2010
 
databases3b
databases3bdatabases3b
databases3b
 
2 Relational Database Concepts.ppt
2 Relational Database Concepts.ppt2 Relational Database Concepts.ppt
2 Relational Database Concepts.ppt
 
Database Tables and Data Types
Database Tables and Data TypesDatabase Tables and Data Types
Database Tables and Data Types
 
Reviewing basic concepts of relational database
Reviewing basic concepts of relational databaseReviewing basic concepts of relational database
Reviewing basic concepts of relational database
 
1. access
1. access1. access
1. access
 
Design your own database
Design your own databaseDesign your own database
Design your own database
 
Database Fundamentals
Database FundamentalsDatabase Fundamentals
Database Fundamentals
 
18 database features
18 database features18 database features
18 database features
 
T-SQL Overview
T-SQL OverviewT-SQL Overview
T-SQL Overview
 
Intro to Data warehousing lecture 12
Intro to Data warehousing   lecture 12Intro to Data warehousing   lecture 12
Intro to Data warehousing lecture 12
 
Database
DatabaseDatabase
Database
 
Database Basics
Database BasicsDatabase Basics
Database Basics
 
MS Sql Server: Introduction To Database Concepts
MS Sql Server: Introduction To Database ConceptsMS Sql Server: Introduction To Database Concepts
MS Sql Server: Introduction To Database Concepts
 

More from determinant342

Personal skills development
Personal skills developmentPersonal skills development
Personal skills development
determinant342
 
Contingent and Quasi contract
Contingent and Quasi contract Contingent and Quasi contract
Contingent and Quasi contract
determinant342
 
Comm. and data communication
Comm. and data communicationComm. and data communication
Comm. and data communication
determinant342
 
Education system in pakistan
Education system in pakistanEducation system in pakistan
Education system in pakistan
determinant342
 
Company meetings
Company meetingsCompany meetings
Company meetings
determinant342
 

More from determinant342 (17)

BP (BEYOND PETROLEUM) FOCUSES ON SUSTAINABILITY
BP (BEYOND PETROLEUM) FOCUSES ON SUSTAINABILITYBP (BEYOND PETROLEUM) FOCUSES ON SUSTAINABILITY
BP (BEYOND PETROLEUM) FOCUSES ON SUSTAINABILITY
 
Personal skills development
Personal skills developmentPersonal skills development
Personal skills development
 
Excel
ExcelExcel
Excel
 
Contingent and Quasi contract
Contingent and Quasi contract Contingent and Quasi contract
Contingent and Quasi contract
 
Consumer perception
Consumer perceptionConsumer perception
Consumer perception
 
Comm. and data communication
Comm. and data communicationComm. and data communication
Comm. and data communication
 
Business plan fastrack
Business plan fastrackBusiness plan fastrack
Business plan fastrack
 
Super Energy Chips
Super Energy ChipsSuper Energy Chips
Super Energy Chips
 
Tracking chips
Tracking chipsTracking chips
Tracking chips
 
IIUI watrer management
IIUI watrer managementIIUI watrer management
IIUI watrer management
 
Cadbury dairy milk
Cadbury dairy milkCadbury dairy milk
Cadbury dairy milk
 
Expansion of Business in Nepal
Expansion of Business in NepalExpansion of Business in Nepal
Expansion of Business in Nepal
 
Education system in pakistan
Education system in pakistanEducation system in pakistan
Education system in pakistan
 
Company meetings
Company meetingsCompany meetings
Company meetings
 
Capitalism
CapitalismCapitalism
Capitalism
 
Comparative advantage of switzerland
Comparative advantage of switzerlandComparative advantage of switzerland
Comparative advantage of switzerland
 
Economic zones
Economic zonesEconomic zones
Economic zones
 

Recently uploaded

Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
MateoGardella
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
Chris Hunter
 

Recently uploaded (20)

Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
 

Database

  • 1. Database BasicsDatabase Basics By: Muhammad NawazBy: Muhammad Nawaz
  • 2. What is a databaseWhat is a database A database is any organized collection ofA database is any organized collection of data.data. Some examples of databases youSome examples of databases you may encounter in your daily life are:may encounter in your daily life are:  a telephone booka telephone book  airline reservation systemairline reservation system  motor vehicle registration recordsmotor vehicle registration records  files on your computer hard drivefiles on your computer hard drive  Employment recordsEmployment records
  • 3. Data vs. information:Data vs. information: What is the difference?What is the difference? What is data?What is data?  Raw Facts and Figures.Raw Facts and Figures. Information science definesInformation science defines data as unprocesseddata as unprocessed information.information. What is information?What is information?  Information is data thatInformation is data that have been organized andhave been organized and communicated in acommunicated in a coherent and meaningfulcoherent and meaningful manner.manner.  Data is converted intoData is converted into information, andinformation, and information is convertedinformation is converted into knowledge.into knowledge.  Knowledge; informationKnowledge; information evaluated and organizedevaluated and organized so that it can be usedso that it can be used purposefully.purposefully.
  • 4. Why do we need a database?Why do we need a database? Keep records of our:Keep records of our:  ClientsClients  StaffStaff Keep sales records;Keep sales records; Develop reports;Develop reports; Perform researchPerform research
  • 5. What is the ultimate purpose ofWhat is the ultimate purpose of a database managementa database management system?system? DataData InformationInformation KnowledgeKnowledge ActionAction Is to transformIs to transform
  • 6. Database management systemsDatabase management systems (DBMS)(DBMS) collections of tools used to manage databasescollections of tools used to manage databases Basic functions performed by all DBMS are:Basic functions performed by all DBMS are: Create, modify, and delete data structures,Create, modify, and delete data structures, e.g. tablese.g. tables Add, modify, and delete dataAdd, modify, and delete data Retrieve data selectivelyRetrieve data selectively Generate reports based on dataGenerate reports based on data
  • 7. Database ModelsDatabase Models a number of different ways of modeling thea number of different ways of modeling the database structure: these are known asdatabase structure: these are known as “database models” (or data models).“database models” (or data models). The model in most common use today isThe model in most common use today is thethe relational model, which in layman'srelational model, which in layman's terms represents allterms represents all information in theinformation in the form of multiple related tables eachform of multiple related tables each consisting of rows and columnsconsisting of rows and columns
  • 8. Databases ComponentsDatabases Components Related tables/RelationsRelated tables/Relations FieldsFields RecordsRecords
  • 9. TablesTables A table is a collection of related records. ForA table is a collection of related records. For example, employee table, product table,example, employee table, product table, customer, and orders tablescustomer, and orders tables In a table, records are represented by rows andIn a table, records are represented by rows and fields are represented as columns.fields are represented as columns.
  • 10. FieldsFields An area (within a record) reserved for a specific piece ofAn area (within a record) reserved for a specific piece of datadata Examples: customer id, customer name, street address,Examples: customer id, customer name, street address, city, phone, current balancecity, phone, current balance defined by:defined by: Field nameField name Data typeData type Field size (Field size (Amount of space reserved for storing dataAmount of space reserved for storing data ))
  • 11. RecordRecord A record is the collection of values for allA record is the collection of values for all the fields belong to one entity: i.e. athe fields belong to one entity: i.e. a person, product, company, transaction,person, product, company, transaction, etc.etc. Key field column(DOB is field)Key field column(DOB is field) recordrecord Customer No Name DOB …… …… ……. 1234 Bilal 10/10/1990
  • 13. RelationshipsRelationships One-to-Many relationship:One-to-Many relationship: Customer-Order, each order has onlyCustomer-Order, each order has only one customer, but a customer can make many ordersone customer, but a customer can make many orders One-to-Many relationships consist of two tables, the "one" table, andOne-to-Many relationships consist of two tables, the "one" table, and the "many“ tablesthe "many“ tables CustomerCustomer OrderOrder 1 m1 m
  • 14. RelationshipsRelationships Many-to-Many relationship: Order-Product, an orderMany-to-Many relationship: Order-Product, an order can contain many products,can contain many products, and a product can be onand a product can be on many ordersmany orders A Many-to-Many relationship consists of three tables:A Many-to-Many relationship consists of three tables: two "one" tables, both in a One-to-Many relationship withtwo "one" tables, both in a One-to-Many relationship with a third table. The third table is sometimes referred to asa third table. The third table is sometimes referred to as the lienthe lien Product OrderProduct Order m nm n
  • 15. Key FieldsKey Fields Primary key:Primary key: A Primary key is a field or a combination of twoA Primary key is a field or a combination of two or moreor more fields. Thefields. The value in the primary key field for each recordvalue in the primary key field for each record uniquely identifies that recorduniquely identifies that record In our previous example, customer number is the Primary key forIn our previous example, customer number is the Primary key for the Customer table. A customer number identifies one and only onethe Customer table. A customer number identifies one and only one customer in the Customer tablecustomer in the Customer table Foreign key: When a "one" table's primary key field is added toForeign key: When a "one" table's primary key field is added to aa related "many" table in order to create the common field whichrelated "many" table in order to create the common field which relates the two tables, it is called a foreign key in the "many" table.relates the two tables, it is called a foreign key in the "many" table. the primary key (customer number) from the Customer table ("one"the primary key (customer number) from the Customer table ("one" table) is a foreign key in the Orders table ("many" table). For thetable) is a foreign key in the Orders table ("many" table). For the "many" records of the Order table, the foreign key identifies with"many" records of the Order table, the foreign key identifies with which unique record in the Customer table they are associated.which unique record in the Customer table they are associated.
  • 16. Data TypesData Types This will hold between 0 and 255 characters. You have to specifyThis will hold between 0 and 255 characters. You have to specify the maximum amount of characters that you will be putting herethe maximum amount of characters that you will be putting here when you create your columnwhen you create your column This will hold as many characters as you like up to 2 gigabytes ofThis will hold as many characters as you like up to 2 gigabytes of spacespace This can hold a value of 0 or 1. It is primarily used for yes/no andThis can hold a value of 0 or 1. It is primarily used for yes/no and true/false issues. It is also referred to as a Boolean or Yes/Notrue/false issues. It is also referred to as a Boolean or Yes/No field.field. This type is used to store decimal numbers. It is primarily used forThis type is used to store decimal numbers. It is primarily used for mathematical purposesmathematical purposes This type indicates that you are storing whole numbers here. YouThis type indicates that you are storing whole numbers here. You can store any whole number between -2147483648 andcan store any whole number between -2147483648 and 21474836482147483648 ● CHARCHAR VARCHARVARCHAR BITBIT FLOATFLOAT INTINT
  • 17. How Do I Create a Table?How Do I Create a Table? Using an SQL statement.Using an SQL statement. CREATE TABLE contacts (CREATE TABLE contacts ( contact_id INT IDENTITY (1, 1) NOT NULL ,contact_id INT IDENTITY (1, 1) NOT NULL , first_name CHAR (30) NULL ,first_name CHAR (30) NULL , last_name CHAR (50) NULL ,last_name CHAR (50) NULL , email VARCHAR (75) NULLemail VARCHAR (75) NULL ););
  • 18. Designing a Table in a DatabaseDesigning a Table in a Database Tool? ….Tool? …. Using Microsoft AccessUsing Microsoft Access
  • 19. INSERT statementINSERT statement INSERT INTO contactsINSERT INTO contacts (first_name, last_name, email)(first_name, last_name, email) VALUES (‘Bilal',‘Afzal',‘bilal@hotmail.com’);VALUES (‘Bilal',‘Afzal',‘bilal@hotmail.com’);
  • 20. What is thatWhat is that NULL thing?NULL thing? NULL is how you tell the DBMS that you have nothing toNULL is how you tell the DBMS that you have nothing to enter in this columnenter in this column
  • 21. UPDATE StatementUPDATE Statement UPDATE contactsUPDATE contacts SETSET email = ‘bilal@hotmail.com‘email = ‘bilal@hotmail.com‘ WHEREWHERE contact_id = 1;contact_id = 1;
  • 22. SELECT StatementSELECT Statement SELECT * FROM contacts;SELECT * FROM contacts; SELECT first_name, emailSELECT first_name, email FROMFROM contactscontacts WHEREWHERE first_name = ‘Bilal';first_name = ‘Bilal';
  • 23. DELETE statementDELETE statement DELETEDELETE FROM contactsFROM contacts WHERE contact_id = 3;WHERE contact_id = 3;
  • 24. Example QueriesExample Queries AND/OR operatorsAND/OR operators SELECT * FROM contacts WHERE(first_name=‘Bilal'SELECT * FROM contacts WHERE(first_name=‘Bilal' ANDAND last_name=‘Afzal')last_name=‘Afzal') OR last_name=‘Ahmed';OR last_name=‘Ahmed'; LIKELIKE SELECT * FROM contact WHERE last_nameSELECT * FROM contact WHERE last_name LIKE '%al';LIKE '%al'; ORDER BY Clause:ORDER BY Clause: SELECT * FROM contacts ORDER BY last_nameSELECT * FROM contacts ORDER BY last_name DESC;DESC;