Course Notes 01
-
Upload
roxana-balag -
Category
Documents
-
view
233 -
download
0
Transcript of Course Notes 01
-
8/3/2019 Course Notes 01
1/73
DataBase course notes - Intro.
DataBase
1
-
8/3/2019 Course Notes 01
2/73
DataBase course notes - Intro.
DataBase people
Me - Calin CENAN
You
2
-
8/3/2019 Course Notes 01
3/73
DataBase course notes - Intro.
DataBase Courses GOAL
to present introduction to database anddatabase management systems
organize information in DBMS
retrieve it efficiently
concentrates on relationalsystems, whichare by far the dominant type of DBMS
today
3
-
8/3/2019 Course Notes 01
4/73
DataBase course notes - Intro.
DataBase Practice GOAL
usea database management system forapplication
MySQL
Structured Query Language SQL
4
-
8/3/2019 Course Notes 01
5/73
DataBase course notes - Intro.
Course Textbooks
R. Ramakrishnan, J. Gerhrke, DatabaseManagement Systems, McGraw Hill, 2002
J. Ullman, H.G. Molina, J. Widom,Database Systems, Prentice Hall, 2001
5
-
8/3/2019 Course Notes 01
6/73
DataBase course notes - Intro.
Course Textbooks
R. Dollinger, Ed. Albastra 2001
Baze de date
Baze de date i gestiunea tranzaciilor Utilizarea sistemului SQL Server (SQL 7.0,
SQL 2000)
6
-
8/3/2019 Course Notes 01
7/73
DataBase course notes - Intro.
Database from Wikipedia
In computer science, a database is astructured collection of records or data thatis stored in a computer system so that a
computer program or person using a querylanguage can consult it to answer queries
7
-
8/3/2019 Course Notes 01
8/73
DataBase course notes - Intro.
Database
Database Management Systems (DBMS)
Database applications
8
-
8/3/2019 Course Notes 01
9/73
DataBase course notes - Intro.
Database management system(DBMS)
computer program used to manage andquery a database
usually categorized according to the datamodel that they support: hierarchical,network, relational, object
9
-
8/3/2019 Course Notes 01
10/73
DataBase course notes - Intro.
Database management system(DBMS) Data Model
data model will tend to determine the querylanguages that are available to access thedatabase
great deal of the internal engineering of a DBMSis independent of the data model, and isconcerned with managing factors such asperformance, concurrency, integrity, and
recovery from hardware failures
10
-
8/3/2019 Course Notes 01
11/73
Data Model
Tyler Farrar
1100100011001010100110101100100110100110
10010 .. Tyler Farrar
June 2, 1984 (age 27)
U.S.A.
1.83 m (6 ft 0 in)
74 kg (160 lb)
Sprinter
Tyler Farrar
DataBase course notes - Intro. 11
-
8/3/2019 Course Notes 01
12/73
DataBase course notes - Intro.
Database Need
amount of information available exploding
value of data as organizational asset iswidely recognized
ability to manage this vast amount of data
quickly find information relevant
need for increasingly powerful and flexibledata management systems
12
-
8/3/2019 Course Notes 01
13/73
DataBase course notes - Intro.
Database Definition
database - collection of data, typicallydescribing the activities of one or more relatedorganizations
database management system, orDBMS, software designed to assist inmaintaining and utilizing large collections
of data need for such systems, as well as their
use, is growing rapidly
13
-
8/3/2019 Course Notes 01
14/73
DataBase course notes - Intro.
Database Importance
there is not real application without a kindof database
great number of DBMS packages can befound on software market, for all types ofcomputers and processing technologies
DBMS can be found at the top 3 of mostneeded, requested, sold and usedproducts
14
-
8/3/2019 Course Notes 01
15/73
DataBase course notes - Intro.
Database: Functional Definition
Database is a stored data collectionhaving the following characteristics:
assures data independence
assures accesses (possibly shared access)to large volumes of data
15
-
8/3/2019 Course Notes 01
16/73
DataBase course notes - Intro.
All DBMS performs 3 main functions
data definition
data manipulation
user interface many other functions that can be carried out
data security
data integrity
data access sharing; data acces control
data recovery
16
-
8/3/2019 Course Notes 01
17/73
DataBase course notes - Intro.
Database
collection of data, typically describing theactivities of one or more related organizations
university database might contain information
about: Entities such as students, faculty, courses, and
classrooms
Relationships between entities, such as students'
enrollment in courses, faculty teaching courses, andthe use of rooms for courses
17
-
8/3/2019 Course Notes 01
18/73
DataBase course notes - Intro.
DataBase ManagementSystem, or DBMS
software designed to assist in maintaining andutilizing large collections of data
alternative to using a DBMS is to use ad hoc
approaches that do not carry over from oneapplication to another
store data in files and write application-specific codeto manage it
18
-
8/3/2019 Course Notes 01
19/73
DataBase course notes - Intro.
Database application
Common interface between language,technology and database SQL Structured Query Language
Architecture Client Server
Web application
19
-
8/3/2019 Course Notes 01
20/73
DataBase course notes - Intro.
Database Web application
20
-
8/3/2019 Course Notes 01
21/73
DataBase course notes - Intro.
Server-side script
web server technology in which a user's request isfulfilled by running a script directly on the web server togenerate dynamic HTML pages
provide interactive web sites that interface to databases
different from client-side scripting where scripts are runby the viewing web browser, usually in JavaScript or anJava applet
primary advantage - ability to highly customize theresponse based on the user's requirements, accessrights, or queries into data stores.
21
-
8/3/2019 Course Notes 01
22/73
DataBase course notes - Intro.
PHP
recursive acronym for "PHP: HypertextPreprocessor
reflective programming language originallydesigned for producing dynamic webpages
used mainly in server-side scripting
22
-
8/3/2019 Course Notes 01
23/73
DataBase course notes - Intro.
PHP
generally runs on a web server
taking PHP code as its input and
creating Web pages as output
acts as a filter
takes input from a file or stream containingtext and special PHP instructions and
outputs another stream of data for display
23
-
8/3/2019 Course Notes 01
24/73
DataBase course notes - Intro.
PHP
can be deployed on most web servers and onalmost every operating system and platform
can be used with a large number of relational
database management systems
over 19 million Internet domains are currently
hosted on servers with PHP installed
24
-
8/3/2019 Course Notes 01
25/73
DataBase course notes - Intro.
LAMP architecture
popular in the Web industry as a way ofdeploying inexpensive, reliable, scalable,secure web applications
PHP is commonly used as the P in thisbundle alongside Linux, Apache andMySQL, although the P can also refer to
Python or Perl
25
-
8/3/2019 Course Notes 01
26/73
DataBase course notes - Intro.
LAMP architecture
solution stack of software
usually free software / open-source software
used to run dynamic Web sites or servers
the original expansion is as follows:
Linux, referring to the operating system;
Apache, the Web server;
MySQL, the database management system PHP, the programming language
26
-
8/3/2019 Course Notes 01
27/73
DataBase course notes - Intro.
LAMP / WAMP architecture
Linux, GNU/Linux a Unix-like computer operating system/ Microsoft Windows families of software operatingsystems
Apache HTTP Serve (http://httpd.apache.org) - free
software/open source web server, the most popular inuse; serves as the de facto reference platform againstwhich other web servers are designed and judged
MySQL (mysql.com) - multithreaded, multi-user, SQLDatabase Management System (DBMS) with more than
ten million installations
27
-
8/3/2019 Course Notes 01
28/73
DataBase course notes - Intro.
LAMP / WAMP architecture
Microsoft Windows-based variant of aLAMP (software bundle)
WAMP5
www.en.wampserver.com
WOS Portable
www.chsoftware.net/en/useware/wos/wos.htm
28
-
8/3/2019 Course Notes 01
29/73
Portable
mowes portable MySQL, Apache Web Server, PHP
MySQL WorkBench
front-end, client, manage MySQL database
DataBase course notes - Intro. 29
-
8/3/2019 Course Notes 01
30/73
Old Time Rock and Roll
Examples based on
Garmin - Cervlo Pro Cycling Team
A Song of Ice and Fire, George RR Martin
DataBase course notes - Intro. 30
-
8/3/2019 Course Notes 01
31/73
Garmin - Cervlo
Tyler Farrar, June 2, 1984, U.S.A., 1.83,74, Sprinter
David Zabriskie, January 12, 1979,U.S.A.,1.83, 67, Time-trialist
David Millar January 4, 1977, UnitedKingdom, 1.92, 76, Time-trialist
Thor Hushovd, 18 January 1978, Norway,1.83, 83, Classics Specialist
DataBase course notes - Intro. 31
-
8/3/2019 Course Notes 01
32/73
Game of Thrones
Bran Stark, House Stark, Westeros
Catelyn Tully, House Stark, Westeros
Daenerys Targaryen, House Targaryen,Valyria
Eddard Stark, House Stark, Westeros
Jon Snow, , The North
Tyrion Lannister, House Lannister, Westeros
Arya Stark, House Stark, Westeros
DataBase course notes - Intro. 32
-
8/3/2019 Course Notes 01
33/73
Game of Thrones
Sansa Stark, House Stark, Westeros
Davos Seaworth, House Seaworth, Westeros
Theon Greyjoy, House Greyjoy, Ironmen
Jaime Lannister, House Lannister, Westeros
Samwell Tarly , , Westeros
Cersei Lannister House Lannister, Westeros
Brienne of Tarth, House Tarth, Westeros
DataBase course notes - Intro. 33
-
8/3/2019 Course Notes 01
34/73
Historical perspective filesystems vs DBMS
have to write special programs toanswer each question a user may wantto ask
must protect data from inconsistentchanges made by different conccurentusers
Restore
Security
DataBase course notes - Intro. 34
-
8/3/2019 Course Notes 01
35/73
Advantage of DBMS
DBMS software designed to make thepreceding tasks easier
Data Independence
Efficient Data Access
Reduced Application Development Time
DataBase course notes - Intro. 35
-
8/3/2019 Course Notes 01
36/73
Advantage of DBMS
Data Integrity and Security
Data Administration
Concurrent Access Crash Recovery
DataBase course notes - Intro. 36
-
8/3/2019 Course Notes 01
37/73
Data Independence
Application programs should not, ideally,be exposed to details of datarepresentation and storage, DBMS
provides an abstract view of the data thathides such details
immunity of user applications to make
changes in the definition and organizationof data
DataBase course notes - Intro. 37
-
8/3/2019 Course Notes 01
38/73
Historical perspective
Integrated Data Store first general-purpose DBMS, designed by CharlesBachman at General Electric in the early
1960s
network data model, standardized byConference on Data Systems Languages
(CODASYL)
DataBase course notes - Intro. 38
-
8/3/2019 Course Notes 01
39/73
Historical perspective
Information Management System (IMS) inthe late 1960s, developed by IBM, usedeven today in many major installations
hierarchical data model
DataBase course notes - Intro. 39
-
8/3/2019 Course Notes 01
40/73
Historical perspective
In 1970, Edgar Codd, at IBM's San JoseResearch Laboratory, proposed
relational data model
DataBase course notes - Intro. 40
-
8/3/2019 Course Notes 01
41/73
Mathematics
always strive for elegance and orthogonality -dislike exceptions
system is said to be designed in an orthogonal
way if its set of components that together makeup whole system capability are non-overlappingand mutually independent
each capability should be implemented by only one
component one component should only implement one capability
of system
DataBase course notes - Intro. 41
-
8/3/2019 Course Notes 01
42/73
Mathematics
well-separated and independent componentsensure that there are no side effects: using oreven changing one component does not cause
side effects in another area of system
formal disciplines, most relevant ones inapplication of mathematics to field of
databases Set theory
DataBase course notes - Intro. 42
-
8/3/2019 Course Notes 01
43/73
Mathematics
Everything should be made as simple aspossible, but not simpler.
Albert Einstein (18791955)
DataBase course notes - Intro. 43
-
8/3/2019 Course Notes 01
44/73
Relational model
Professionals in any discipline need toknow the foundations of their field
Database Professional - need to knowtheory of relations
is not product-specific;
rather, it is concerned with principles
DataBase course notes - Intro. 44
-
8/3/2019 Course Notes 01
45/73
Principles, not Products
principle
source, root, origin; which is fundamental;essential nature; theoretical basis
principles endure
by contrast, products and technologies,change all the time
DataBase course notes - Intro. 45
-
8/3/2019 Course Notes 01
46/73
E. F. Codd, at the time researcher at IBM;late in 1968 that Codd, a mathematician,first realized that discipline of mathematics
could be used to inject some solidprinciples and rigor into field of database
DataBase course notes - Intro. 46
i i l d fi iti f
-
8/3/2019 Course Notes 01
47/73
original definition ofrelational model
E. F. Codd
Derivability, Redundancy, and Consistency ofRelations Stored in Large Data Banks, IBM ResearchReport RJ599, 1969.
A Relational Model of Data for Large Shared DataBanks, CACM 13, No. 6, 1970.
C. J. Date
An Introduction to Database Systems, 8th
Ed. Boston,Mass.: Addison-Wesley, 2004.
first edition of book was published in 1975
DataBase course notes - Intro. 47
R l ti l d l
-
8/3/2019 Course Notes 01
48/73
Relational modelthree major components
structure
integrity
manipulation
DataBase course notes - Intro. 48
-
8/3/2019 Course Notes 01
49/73
Set theory
branch of mathematics
studies sets - collections of objects
probably remember your math teacherdrawing pictures on blackboard whileexplaining sets (Venn diagrams)
DataBase course notes - Intro. 49
-
8/3/2019 Course Notes 01
50/73
Set theory
branch of mathematics
studies sets - collections of objects
probably remember your math teacherdrawing pictures on blackboard whileexplaining sets (Venn diagrams)
DataBase course notes - Intro. 50
-
8/3/2019 Course Notes 01
51/73
Set
primitive terms
collection of objects, those objects arecalled elements of set
fully characterized by its distinct elements,and nothing else but these elements
DataBase course notes - Intro. 51
-
8/3/2019 Course Notes 01
52/73
Set
elements of set dont have any ordering
dont contain duplicate elements
x S
DataBase course notes - Intro. 52
-
8/3/2019 Course Notes 01
53/73
Methods to specify sets
Enumerative Method
Predicative Method
DataBase course notes - Intro. 53
-
8/3/2019 Course Notes 01
54/73
Cartesian Product
A x B { (a;b) | a A b B }
DataBase course notes - Intro. 54
-
8/3/2019 Course Notes 01
55/73
Relation
Relative
Catelyn Tully is the mother of Bran Stark
Eddard Stark is the father of Bran Stark
x Rel y
catelyn Mother bran
eddard Father bran
bran Child catelyn
bran Child eddardDataBase course notes - Intro. 55
-
8/3/2019 Course Notes 01
56/73
Relation
1 Square 1
2 Square 4
3 Square 9
4 Square 16
16 Square 256
1.41 Square 2
DataBase course notes - Intro. 56
-
8/3/2019 Course Notes 01
57/73
Binary Relation
from set A to set B is defined as subset ofCartesian product A x B
A := {X,Y,Z}, B := {1,2}
R1 := { (X;1), (X;2), (Y;1), (Z;2) }
DataBase course notes - Intro. 57
-
8/3/2019 Course Notes 01
58/73
Function
binary relation that doesnt have two
elements that have the same firstcoordinate
DataBase course notes - Intro. 58
-
8/3/2019 Course Notes 01
59/73
Relation
subset of generalized Cartesian product
set of tuples (N-Tuples)
tuple ordered list of elements
{(e1; e2; ; en) | ei Si}
DataBase course notes - Intro. 59
-
8/3/2019 Course Notes 01
60/73
(Father, Mother, Child)
eddard, catelyn, bran
eddard, catelyn, arya
eddard, catelyn, sansa
eddard, catelyn, robb
tywin, joanna, jaime
tywin, joanna, tyrion tywin, joanna, cersei
hoster, minisa, catelynDataBase course notes - Intro. 60
-
8/3/2019 Course Notes 01
61/73
Sets
Name
Date of Born
Country
Height
Weight
Rider type {Sprinter, Time-trialist, ClassicsSpecialist}
DataBase course notes - Intro. 61
-
8/3/2019 Course Notes 01
62/73
Tuple (N-Tuple) element of relation
Name - Tyler Farrar
Date of Born - June 2, 1984
Country U.S.A.
Height - 1.83
Weight - 74
Rider type - Sprinter
DataBase course notes - Intro. 62
-
8/3/2019 Course Notes 01
63/73
Tuple (N-Tuple) element of relation
(Tyler Farrar; June 2, 1984; U.S.A.; 1.83;74; Sprinter)
Name - Tyler Farrar
Date of Born - June 2, 1984
Country U.S.A.
Height - 1.83 Weight - 74
Rider type SprinterDataBase course notes - Intro. 63
-
8/3/2019 Course Notes 01
64/73
Relation
{
(Tyler Farrar; June 2, 1984; U.S.A.; 1.83; 74; Sprinter),
(David Zabriskie; January 12, 1979; U.S.A.; 1.83; 67;Time-trialist),
(David Millar; January 4, 1977; United Kingdom; 1.92;76; Time-trialist),
(Thor Hushovd; 18 January 1978; Norway; 1.83; 83;Classics Specialist),
(Andrei Nechita; 29 May 1988; Romania; NULL; NULL;NULL)
}
DataBase course notes - Intro. 64
-
8/3/2019 Course Notes 01
65/73
Relation subset - set
Elements
elements of set dont
have any ordering
dont contain duplicateelements
Specify sets
Enumerative Method
Predicative Method
DataBase course notes - Intro. 65
-
8/3/2019 Course Notes 01
66/73
Relation
are defined over domains, (data types)
domain set of values from which actualattributes in actual relations take their
actual values
n-ary relations can be pictured as tablewith ncolumns
columns correspond to attributes of relation
rows correspond to tuples
DataBase course notes - Intro. 66
-
8/3/2019 Course Notes 01
67/73
Relational Algebra
DataBase course notes - Intro. 67
-
8/3/2019 Course Notes 01
68/73
Properties of Relations
every relation has headingand body
heading is set of attributes (name, typepair)
body is set of tuples that conform to thatheading
relation doesn't really contain tuples, itcontains body, and that body in turncontains tuples
DataBase course notes - Intro. 68
-
8/3/2019 Course Notes 01
69/73
Properties of Relations
number of attributes in heading is thedegree(arity), and number of tuples inbody is the cardinality
tuples of relation are unordered; followsbecause body is set, and sets inmathematics have no ordering to their
elements attributes of relation are also unordered
because heading too is mathematical setDataBase course notes - Intro. 69
-
8/3/2019 Course Notes 01
70/73
Properties of Relations
relations never contain duplicate tuples;follows because body is set of tuples, andsets in mathematics do not contain
duplicate elements relational operations always produce result
without duplicate tuples
SQL results are allowed to containduplicate rows
DataBase course notes - Intro. 70
-
8/3/2019 Course Notes 01
71/73
Tuple
Let T1, T2, ... , Tn, (n> 0) be type names, not necessarilyall distinct.
Associate with each Ti a distinct attribute name, Ai; eachof the nattribute-name : type-name combinations that
results is an attribute. Associate with each attribute a value vi of type Ti; each
of the nattribute : value combinations that results iscomponent.
set of all ncomponents thus defined, tsay, is tuple value(or just tuple for short) over the attributes A1, A2, ... , An
value n is the degree of t; set of all nattributes isheading of t
DataBase course notes - Intro. 71
-
8/3/2019 Course Notes 01
72/73
Relation
Let {H} be a tuple heading and let t1, t2, ... , tn, (n> 0) be distinct tuples with heading {H}.
The combination, rsay, of {H} and the set of
tuples {t1, t2, ... , tn} is a relation value (or justrelation for short) over attributes A1, A2, ... , An,where A1, A2, ... , An are the attributes in {H}.
heading of r is {H}
rhas same attributes that heading does
body of ris set of tuples {t1, t2, ... , tn}
DataBase course notes - Intro. 72
-
8/3/2019 Course Notes 01
73/73
Thank you for your kindly attention!