Intro_to_DBMS 1
Intro_to_DBMS 1
to DBMS
What is Data?
Database is anything that collects and organizes data (collection of related data)
• Relational
• Distributed
• Hierarchical
• Object-oriented and
• Network.
What is a Table?
Table stores data in row and column format and makes it easy for people to use the data.
Columns/Variables/features/attributes
Primary Key!!
❑ A Primary key is a unique column we set in a table to easily identify and locate data in queries.
❑ The primary key column has a unique value and doesn’t store repeating values. A Primary key
can never take NULL values.
Data Types in SQL
Strings Varchar: A VARIABLE length string (can contain letters, numbers, and special characters) 0 to 65535
Char: A FIXED length string (can contain letters, numbers, and special characters)..0 to 255, default is 1
Date& timestamp
https://paiza.io/en/languages/mysql
What is SQL?
Characteristics of SQL
7. Best Suited for the Client-Server Environment
1. Easy to learn
8. Integration
2. Wide Variety of Commands 9. High performance
3. Stored Procedures 10. Scalability and Flexibility
4. Portable Language 11. Transactions
5. Joins 12. Security
6. Union
Database Languages Wide Variety of Commands
Flat Files
• It contains flat files that have no relation to other files (when only one table is
stored in a single file, then this file is known as a flat file).
Example: The data that we store in our personal laptops in folders/sub folders etc. uses
FILE SYSTEM ( a way of storing data)
Advantages of DBMS over File system: Fast and Esay to Operate
Data security: In DBMS we can provide Role based access (based on job level etc.) or read/Write etc.
Data Redundancy: Duplicacy of data is not allowed in DBMS as we have constraints for this.
Data Inconsistency: When we restrict duplicate entries, we will automatically protect data from inconsistency
Data location: We do not need to know the location of data/file to fetch/access it in DBMS.
• Data Model
1. Relational Model
2. Entity Relationship Model
3. Object-based Model
4. Semi-structured Data Model
Collection of tables
Relational Tables=Relations
ORDER table
CUSTOMER table
Why Separate Tables?
Normalization!!!
Non-Normalized table
ORDER table
CUSTOMER table
❑ A Primary key is a unique column we set in a table to easily identify and locate data in queries.
❑ The primary key column has a unique value and doesn’t store repeating values. A Primary key
can never take NULL values.
FOREIGN KEY
❑ A FK is a field in one table (child table) that refers to the primary key in another table (parent
table).
❑ A foreign key comes to use when we need to link tables to one another and have data spread
over multiple table
• UNIQUE KEY
• We can have multiple unique keys
• We can have unique keys on different columns
• The purpose of unique key is to make sure the values do
not duplicate.
• NOT NULL
• In SQL, null or NULL is a special marker used to indicate that a
data value does not exist in the database. Introduced by the
creator of the relational database model
• A NULL value is different from a zero value or a field that contains
spaces. A field with a NULL value is one that has been left blank
during record creation
• CHECK
• The CHECK constraint is used to limit the value range that can be
placed in a column.
1. Relational Model
2. Entity Relationship Model
3. Object-based Model
4. Semi-structured Data Model
Entity Relationship Model
Schematic/Diagrammatic
Collection of basic
E-R Data Model or ER An entity is a real world Distinguishable from Widely used in database representation so that
objects called entities
Model thing or object. other objects. design. this can be used in
and its relationship.
designing database
Entity
Attribute
Multivalued attributes
Employee
Derived
attribute
• Weak entity
Q. Construct an ER
diagram with a hospital,
set of patients and a set
of doctors.
Enhanced ER
Diagram (Advanced
DBMS)
• Subclasses and Super
classes (subclass inherits
attributes of superclass)
• Generalization and
specialization
• Disjoint and overlapping
constraints
• Hierarchy and lattice
• Total and partial
participation
While designing if top to While designing if bottom
down model approach is to top approach is used it is
used it is known as known as generalization.
specialization.
Three level architecture( Abstraction)/Data Independence
DBMS
Architecture/Component/Structure
• What Is an SQL operator?
• Arithmetic Operators
• Comparison Operators
• Logical Operators
Arithmetic SQL
Operators
• Arithmetic operators are
used to perform arithmetic
operations such as
addition, subtraction,
division, and multiplication.
• These operators usually
accept numeric operands.
• Different operators that
come under this category
are given below-
• Comparison SQL Operators
An information system is made up of five components: hardware, software, data, people, and process.
System Development Life Cycle (SDLC)
Developers turn the SRS document they created into a more logical structure
that can later be implemented in a programming language
Development Stage
Developers actually write code and build the application according to the
earlier design documents and outlined specifications.
Testing Stage
During the testing stage, developers will go over their software with a fine-tooth comb, noting
any bugs or defects that need to be tracked, fixed, and later retested.
After testing, the overall design for the software will
come together.
•Attributes: MatchID (foreign key referencing Match), PlayerID (foreign key referencing Player), etc.
5.Score: Represents the scores in each match.
•Attributes: ScoreID (primary key), MatchID (foreign key referencing Match), TeamScore, OpponentScore,
etc.
•Attributes: StatID (primary key), MatchID (foreign key referencing Match), PlayerID (foreign key referencing
Player), GoalsScored, Assists, YellowCards, RedCards, etc.
7.SummaryStatistics: Represents summary statistics derived from matches and player statistics.
•Attributes: SummaryID (primary key), TeamID (foreign key referencing Team), TotalMatchesPlayed,
TotalWins, TotalLosses, TotalGoalsScored, etc.
The relationships between these entities can be represented as
follows: