Relational Databases
Relational Databases
History of ER
- Peter Chan 1971
-
What is ER Diagrams?
- This model occurs with
visualisation of plan
- The diagram represents the
database and the relation
between the tables
- Each column will be represented
by a key
- These keys help connect tables.
The keys include
primary/foreign key, secondary
key
- We use the same symbols to
define each table/make them
unique
- all documents are shareable.
this helps with the team work
Why use ER Diagrams?
- A way to demonstrate data efficiently
- Easy and clear
- Shareable
- Can demonstrate relations between tables
- Easily modifiable
- Expandable
- Comprehensive
Components of the ER Diagram
- Entity
- Attribute
- Relation
-
Attributes
• Attributes can be defined my
symbol and context/content
Type of attributes
- string
- char
- int
- bool
Cardinality
- The four basic relations
demonstrated here are enough
- If a many-to-many relation is
created it’d create a weak entity
set
-
ER- Diagram Notations
- Strong entity: rectangle
- Weak entity: double
- Attributes: oval
- Relation: line with symbols
- Mandatory: small line
- optional: small circle
- one: small line
- Many: 3 lines
Steps to Create an ERD
1.
2.
3.
4.
5.
Developing Effective ER Diagrams
- Create strong entity sets
- Use easy-to-read naming and symbols
- Clear symbols
- Not to connect tables with same keys
-
-
-
Relational databases
Data and Database
•-
•-
•-
•-
•-
Data independences
• Type of data independences
• Physical
• Logical
Examples of changes under Physical Data
Independence
•-
•-
•-
•-
•-
•-
•-
Logical Data Independence
• External views
• External API or programs
Examples of changes under Logical Data
Independence
•-
•-
•-
Difference between Physical and Logical Data
Independence
• Logical data independence • Physical data independence
- -
- -
- -
- -
- -
- -
- -
Importance of Data Independence
-
-
-
-
-
-
-
-
Levels of Database
-
-
-
Type of schema
1.
2.
3.
Relation models
Relation model concepts
• 1. Attribute
• 2. Tables
• 3. Tuple
• 4. Relation Schema
• 5. Degree
• 6. Cardinality
• 7. Column
• 8. Relation instance
• 9. Relation key
• 10. Attribute domain
Relational Integrity constraints
1.
2.
3.
Operations in Relational Model
-
-
-
-
Advantages of using Relational model
•-
•-
•-
•-
•-
•-
Disadvantages of using Relational model
1.
2.
3.
Relational database systems.
The SQL language, DDL, DML,
DCL. Schema, relations and
relation operations in SQ
RDMS
• designed specifically for relational databases
• RDBMSes are a subset of DBMSes
Relational database
• Database
• Rows
• Columns
• Applications
Non-relational databases
• Apache Hbase
• IBM Domino
• Oracle NoSQL Database
SQL
• Structured Query Language
• MySQL
• MS Access
• Oracle
• Sybase
• Postgres
• SQL Server
Why Use SQL?
• It helps users to access data in the RDBMS system.
• It helps you to describe the data.
• It allows you to define the data in a database and manipulate that
specific data.
• With the help of SQL, you can create and drop databases and tables.
• SQL offers you to use the function in a database, create a view, and
stored procedure.
• You can set permissions on tables, procedures, and views.
Types of SQL
• UPDATE
• DELETE
DDL vs. DML
- The DML statements allow you to
• Allows you to store shared data
modify the data stored in a
• Data independence improved database.
integrity
- Users can specify what data is
• Allows multiple users needed.
• Improved security efficient data - DML offers many different flavors
access and capabilities between database
vendors.
- It offers an efficient human
interaction with the system
DCL
• GRANT SELECT, UPDATE ON MY_TABLE TO SOME_USER,
ANOTHER_USER
-
-
What is the key?
Primary key
-
-
-
-
-
-
What is the composite key?
2NF rules
ID Name DoB.
1 Dr. Margit Pap 1955
2 Dr. Zoltan Horvath 1979
2 Dr. Zoltan Horvath 1979
3 Dr. Norbert Zentai 1982
ID Job position
1 Director
2 Prof. assistant
2 Erasmus coordinator
• Rule 1- Be in 1NF 3 Lecturer
• Rule 2- Single Column Primary Key
Foreign Key
-
-
-
-
Foreign key
• Insert a record in Table B
ID Job Title
5 Visitor professor
Consider the table 1. Changing the non-key column Name may change Date of Birth
3NF
ID Name Job title DoB
1 Dr. Margit pap Director 1955
2 Dr. Zoltan Horvath Prof. Assistant 1979
2 Dr. Zoltan Horvath Erasmus coordinator 1979
Product
Date
code
Pieces
Sumvalu Payment Productname Price
• Date Date Pcode
Pcode
• SumValue
Pname
• Payment Pieces Price
Which NF is this?
Date SumValue Payment
88.02.03 4140 3140
88.02.04 4620 3620
88.02.05 3600 2600
88.02.06 4620 3620
Date SumValue
SumValue Payment
Payment{SumValue,Payment}
SumValue Payment
4140 3140
4620 3620
3600 2600
Parts{Pcode,Pname,Price}
• Based on Actions
• Based on Structure
Schedule
Initial Product Quantity is 10
Transaction 1: Update Product Quantity to 50
Transaction 2: Read Product Quantity
Type of equivalence
1. RESULT EQUIVALENCE
2. View Equivalence
3. CONFLICT Equivalence
Serializability
• Conflict
• View
Data warehouse
Data warehouse
•
Charactheristic
Operations
Operations
N dimension’s datamodell’s
Business intelligense
Goals
Data warehouse vs data modells
OLTP Data warehouse
Domináns műveletek Maintenance (updating) Complex queries involving
operations involving data large data sets. Grouping
involved in a transaction: and ranking of individuals
insertion, modification, (objects, events) according
deletion to certain criteria, as well
as according to a given
grouping or
hierarchyreaching