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

lecture+1

Uploaded by

tynysbekn
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

lecture+1

Uploaded by

tynysbekn
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 22

Databases Design.

Introduction to SQL

LECTURE 1

Introduction

IITU, ALMATY
Course information
• Lectures
• Lab works + Quizzes (as defense)
(individual work, University database)
• Project
(teams of 1-3 students, individual topic)

• Midterm / End of term – quizzes


• Final exam – practice task + quiz
Relational database

• generally, each table represents one entity


(such as Students).
• the rows represent instances of that type of
entity (such as student1, student2, etc.)
• the columns representing values attributed to
that instance (such as stud_id, last_name,
etc.)
Entity (table,
Attribute (column, relation)
field)

Students
phone_
stud_id last_name DOB
number
001 student1 01.01.2000 1234567

Tuple 002 student2 … …


(row,
record) 003 student3 … …
Primary Key
• A PK is a column in a table which uniquely
identifies each row in a table.

• PK must contain unique values, and cannot


be empty.

• A table can have only one PK.


• PK often (but not always) consists of single
column (field).
Database Design
Stages

1. Subject Area Analysis


2. Conceptual Design
3. Logical Design
4. Physical Design
By the end of this course students will be
able to:
• Design a database starting from the first
stage to the physical implementation

• Demonstrate the programming skills with


SQL (Structured Query Language)

• Work with the database management


system (DBMS)
Subject Area Analysis. Step 1
1. Specify stored information in the future database in the
following way: "The database is designed to hold
information relating to/ about ...".

• Databases can contain completely different information


about the educational process. Moreover, even in one
university there can be several databases storing
different information.
• List in detail what information will be stored in your
future database. For example, personal information
about students, teachers, courses, etc.
Subject Area Analysis. Step 2
2. List entities and attributes (in other words, tables and
columns of the future database).

• List all tables in the required format. Every entity


should have a Primary key, underline it in the
description.

• Examples.
Students (stud_id, last_name, first_name, DOB,
phone_number)
Groups (group_id, name, email)
Subject Area Analysis. Step 3
3. List and describe all relationships between entities.

• Important elements of relational databases are also


relationships between tables.
• Relationships are used to connect rows of different
tables with each other.
• Relationships should not exist between all tables in the
database, but only between those where it makes
sense.
Subject Area Analysis. Step 3
To describe a relationship between two tables, answer 2
questions.
First of them is how one row from the first table refers row(s)
from the second table, and the second question (from the
other side) is how one row from the second table refers row(s)
from the first table.

1 student 1 group

Students Groups
many students 1 group
Subject Area Analysis. Step 4
4. List all constraints.

• The database reflects the real world, therefore, all restrictions that
exist at the real world should be reflected in the database for
convenient work.
• However, constraints should only apply to the information that is
stored in the database, otherwise they cannot be implemented. For
example, the Students table stores the date of birth, so we can write
the following constraint.

• Example.
Student’s date of birth must be later than 1980.
Subject Area Analysis. Step 5
5. Specify all groups of users and their access rights.

• Database is used by different groups of users, and they have


different access rights. A group of users is all users who have
the same access rights.
• Specify access rights at the table level - access can be read-
only or read-write, in other words, write which tables these
users will be able to edit, and which - only view.

• Example.
User group: Students. Access rights: table Schedule (read-only).
Subject Area Analysis. Step 6
6. List all potential queries from users.

• Users will be able to get information from the database


by writing a query. In other words, a query is a question
to the database to display certain information.

• Example.
Show last names of students by the name of a group
(show all students from the IT2-2101).
Show information about all groups.
Database management systems
Database management systems
(DBMSs) are specially designed
applications that interact with the user,
other applications, and the database itself
to capture and analyze data.

DBMS is a software system designed to


allow the creation, querying, and
administration of databases.
Simplified database system
environment
Database management systems

• PostgreSQL
• MS Access
• MS SQL Server
• Oracle
• MySQL
• etc
Why learn about databases?
• Nowadays databases are everywhere, but we
never see them. They are hidden behind the
tools and services that we use everyday.

• Almost any business has a database.


• It used to be about only boring things:
employee records, bank records, etc.
• However, databases are behind almost
everything you do on the Web. For example,
social networks.
Ideas for a Project:
institutions
bank
airport
hospital
hotel
restaurant
library
publishing house
travel agency
fitness club
Ideas for a Project:
social networks
vk.ru / fb.com
instagram.com
twitter.com
last.fm (music)
livelib.ru / goodreads.com (books)
blog platform
linkedIn.com
tripadviser.com (travel)
Ideas for a Project:
sales
on-line store
book store
car sales
ticketon.kz
kino.kz
airastana.com
Literature
• Connolly, Thomas M. Database Systems: A Practical
Approach to Design, Implementation, and Management /
Thomas M. Connolly, Carolyn E. Begg.- United States of
America: Pearson Education

• Garcia-Molina, H. Database system: The Complete


Book / Hector Garcia-Molina.- United States of America:
Pearson Prentice Hall

• Sharma, N. Database Fundamentals: A book for the


community by the community / Neeraj Sharma, Liviu
Perniu.- Canada

You might also like