Trong lĩnh vực Công Nghệ Thông Tin nói riêng, yêu cầu quan trọng nhất của người học đó chính là thực hành. Có thực hành thì người học mới có thể tự mình lĩnh hội và hiểu biết sâu sắc với lý thuyết. Với ngành mạng máy tính, nhu cầu thực hành được đặt lên hàng đầu. Tuy nhiên, trong điều kiện còn thiếu thốn về trang bị như hiện nay, người học đặc biệt là sinh viên ít có điều kiện thực hành. Đặc biệt là với các thiết bị đắt tiền như Router, Switch chuyên dụng
Trang 1Giảng viên: Trần Thị Kim Chi
Trang 2Introduction SQL Server
3
2 What is Database Management System
Introduction about SQL Server 2008
Trang 3• Data is raw, unorganized facts that need to be processed.
Data are any facts, numbers, or text that can be processed
by a computer
• Information
– When data is processed, organized, structured orpresented in a given context so as to make it useful, it iscalled information
Data and Information
1
Data (dữ liệu) và information (thông tin)
DỮ LIỆU (DATA)
THÔNG TIN (INFORMATION)
XỬ LÝ
Trang 4Data (dữ liệu) và information (thông tin)
Thông tin: dữ liệu trong ngữ cảnh
STT Mã sinh viên Họ và tên sinh viên Lớp Tuổi
…
Dữ liệu
…
Trang 5 A data model is a “description” of both a container for dataand a methodology for storing and retrieving data fromcontainer
Data model is
Not a thing
You cannot touch it
Data model are abstractions, mathematical algorithms & Concepts.
Data Model
1
Trang 6• A database a set of data that has a regular structure andthat is organized in such a way that a computer can easilyfind the desired information.
Database
Application Program 2 Application Program 1
Application Programs
Trang 7Database management systems follow particular models (known as database models) to store and manipulate
data
A database model is characterized by:
2 The way data in the
Trang 8• Persistent:
– Should be able to store all kinds of data that exists in this real world.
• Interrelated:
– Data and application should be isolated.
– Should be able to relate the entities / tables in the database by means of a relation i.e.; any two tables should be related.
• Shared:
– Multiple users should be able to access the same database, without affecting the other user.
– Database should also provide security,
– Database should also support ACID property i.e.; while performing any transactions like insert, update and delete, database makes sure that the real purpose of the data is not lost.
Trang 9 Objective
Ensuring data completeness
Avoiding data redundancies
Facilitating data access
Trang 10 Requirement analysis
What does the user want?
Conceptual database design
Defining the entities and attributes, and the
relationships between these The ER model
Physical database design
Implementation of the conceptual design using a
Database Management System
Steps in Database Design
Trang 11ER model & Relational Data Model
Bundoora Norman
8507
Balwyn Mary
8452
Bundoora Glen
3936
Kew Robert
1108
Suburb Name
Id
Student
Takes
29 8507
23 8507
23 1108
21 1108
SNO SID
CSCE VB
29
Maths Algebra
18
CSCE Database
23
CSCE Systems
21
Dept Name
No
Subject
Bundoora Norman
8507
Balwyn Mary
8452
Bundoora Glen
3936
Kew Robert
1108
Suburb Name
Id
Student
Takes
29 8507
23 8507
23 1108
21 1108
SNO SID
CSCE VB
29
Maths Algebra
18
CSCE Database
23
CSCE Systems
21
Dept Name
No
Subject
Relational Database
Entities:
Student (Id, Name, Suburb)
Subject (No, Name, Dept)
Relationships:
Student
Subject
Takes
ER models view the world by entities and relationships
Relational models view the world by relations
Trang 13• “A DBMS that manages data
as collection of tables in which
all data relationships are
represented by common values
in related tables.”
•“A DBMS that follows all the
twelve rules of CODD is called
Trang 14• Table: information about a
single entity
• Primary key: (set of)
column(s) that uniquely
identifies a record
• Foreign key: (set of)
column(s) used to link table
Trang 15TABLE Structure
Attributes
Cardinality
Primary Key
Tuples
Supplier
DomainDomain
Trang 16The Relational Database
Trang 17• Chitiethoadon: Mô tả các thông tin chi tiết của từng hóađơn như Mahd, Masp, Soluong, DongiaBan.
Example: TABLE Structure
Trang 18Example: TABLE Structure
Trang 19Bài tập
Việc quản lý nhân viên của một công ty như sau:
• Công ty gồm nhiều nhân viên, mỗi nhân viên có một MANV duy nhất, mỗi MANV xác định Hoten, Phai, NgaySinh, Phongban Mỗi nhân viên chỉ do một phòng ban quản lý.
• Mỗi phòng ban có một MAPB duy nhất, mỗi MAPB xác dịnh TenPB, DiaDiem, MaTP (Mã người phụ trách), KPHD(Kinh phí hoạt động), DT (Doanh thu của từng phòng ban).
• Nhân viên được chia làm hai loại nhân viên Nhân viên hành chánh và nhân viên tham gia sản xuất Nhân viên hành chánh làm việc theo giờ hành chánh Nhân viên tham gia sản xuất thì làm nhiều công việc khác nhau.
• Mỗi công việc có một mã MACV, Macv xác định TENCV, DONGIA Công ty có tối đa
Exercise
Trang 20Bài tập
Câu hỏi:
• Xây dựng mô hình thực thể kết hợp gồm: Xác định các thực thể, thuộc tính, khóa, các mối kế hợp và vẽ
mô hình thực thể kết hợp
• Chuyển mô hình thực thể về lược đồ cơ sở dữ liệu quan hệ và xác định các khóa
• Xác định các mối quan hệ và các ràng buộc của lược
đồ cơ sở dữ liệu trên
Trang 21Advantages
• Reduced data redundancy
• Reduced updating errors and increased consistency
• Greater data integrity and independence from
applications programs
• Improved data access to users through use of host and query languages
• Improved data security
• Reduced data entry, storage, and retrieval costs
• Facilitated development of new applications program
Trang 22• Database systems are complex, difficult, and consuming to design
time-• Substantial hardware and software start-up costs
• Damage to database affects virtually all applicationsprograms
• Extensive conversion costs in moving form a file-basedsystem to a database system
• Initial training required for all programmers and users
Trang 23• DataBase Management System (DBMS)
– A database management system (DBMS) is systemsoftware for creating and managing databases TheDBMS provides users and programmers with asystematic way to create, retrieve, update andmanage data
DBMS – DataBase Management System
Trang 24DBMS – DataBase Management System
Components of Database System
• Users : Users may be of various type
such as DB administrator, System
developer and End users.
• Database application : Database
Departmental, Enterprise and Internal
• DBMS : Software that allow users to
define, create and manages database
access, Ex: MySql, Oracle etc.
• Database : Collection of logical data.
Trang 25CHARACTERISTICS OF THE DATABASE MANAGEMENT
SYSTEM
• Data Independence: The DBMS provides an abstract view of the
data that hides such details
• Efficient Data Access: A DBMS utilizes a variety of sophisticated
techniques to store and retrieve data efficiently
• Data Integrity and Security: If data is always accessed through
the DBMS, the DBMS can enforce integrity constraints
DBMS – DataBase Management System
Trang 26CHARACTERISTICS OF THE DATABASE MANAGEMENT
SYSTEM
• Data Administration: When several users share the data,
Experienced professionals who understand the nature of the data being managed, and how different groups of users use it, can be responsible for organizing the data representation to minimize redundancy and for fine tuning the storage of the data to make retrieval efficient
• Concurrent Access and Crash Recovery: A DBMS schedules
concurrent accesses to the data in such a manner that users can think of the data as being accessed by only one user at a time
Further, the DBMS protects users from the effects of system
failures
DBMS – DataBase Management System
Trang 27Functions of DBMS
• Provides data Independence
• Concurrency Control
• Provides Recovery services
• Provides Utility services
• Provides a clear and logical view of the process that
manipulates data
DBMS – DataBase Management System
Trang 28Quan hệ
Trang 29Quan hệ
• Database (Data) Tier: the database resides
along with its query processing languages We
also have the relations that define the data and
their constraints at this level.
• Application (Middle) Tier: reside the
application server and the programs that
access the database For a user, this
application tier presents an abstracted view of
the database The application layer sits in the
middle and acts as a mediator between the
end-user and the database.
• User (Presentation) Tier − End-users operate
on this tier and they know nothing about any
existence of the database beyond this layer At
this layer, multiple views of the database can be
provided by the application All views are
generated by applications that reside in the
application tier.
Trang 30SERVICES OF DBMS
• Data Storage Management
• Data Manipulation Management
• Data Definition Services
• Data Dictionary/System Catalog Management
• Database Communication Interfaces
• Authorization / Security Management
• Backup and Recovery Management
• Concurrency Control Service
• Transaction Management
• Database Access and Application Programming Interfaces
DBMS – DataBase Management System
Trang 32Advantages of a DBMS
• Segregation of applicaion program
• Minimal data duplicacy
• Easy retrieval of data
• Reduced development time and maintainance need
DBMS – DataBase Management System
Trang 34• RDBMS stands
for Relational Database Management System RDBMS is the
basis for SQL, and for all modern database systems like MS SQL Server, IBM DB2, Oracle, MySQL, and Microsoft
Access
• A Relational database management system (RDBMS) is a database management system (DBMS) that is based on the relational model as introduced by E F Codd
Table 1 Key Data
Table 2 Key
Quan hệ
Database
Relational Database Management System
Trang 35Hardware and Software
requirements are minimum requirements are HighHardware and Software
Platform used is normally DOS Platform used can be any DOS,
UNIX,VAX,VMS, etc Uses concept of a file Uses concept of table
DBMS normally use 3GL RDBMS normally use a 4GL
Examples are dBase, FOXBASE, etc Examples are ORACLE, INGRESS,
SQL Server, Access, etc
Trang 36• SQL stands for Structured Query Language
• Microsoft SQL Server is a relational database
management system developed by Microsoft
• The primary query languages: T-SQL and ANSI SQL
• SQL Server includes several components
• Primary function: store and retrieve data as requested
by other software applications on the same computer or
on another computer across a network
Trang 37Storage Engine
Server
Local Database
Database API (OLE DB, ODBC, DB-Library)
Trang 38Client/Server Architecture
Relational Database Management System
SQL Server Client
Results
Client Application
OLAP OLTP
Query
Trang 39Ms SQL Server Components
Trang 40• SQL Server Integration Services (SSIS) is a platform
for building high performance data integration solutions,including extraction, transformation, and load packagesfor data warehousing
Ms SQL Server Components
Trang 41• SQL Server Database Engine is the core service for
storing, processing, and securing data
– This includes creating tables for storing data, anddatabase objects such as indexes, views, and storedprocedures for viewing, managing, and securing data
Ms SQL Server Components
Trang 42• SQL Server Reporting Services (SSRS) includes:
– A complete set of tools that you can use to create andmanage reports,
– An application programming interface (API) thatallows developers to integrate or extend data andreport processing in custom applications
Ms SQL Server Components
Trang 43SQL Server Analysis Services :
• Analysis Services delivers Online Analytical Processing
and Data Mining functionality for Business Intelligence applications
Ms SQL Server Components
Trang 44SQL Server Service Broker :
• Service Broker, internal or external processes can send and receive guaranteed, asynchronous messages by using extensions to Transact- SQL Data Manipulation Language (DML)
• Messages can be sent to a queue in the same database as the sender,
to another database in the same SQL Server instance, or to another SQL Server instance either on the same server or on a remote server.
Ms SQL Server Components
Trang 45• SQL Server Replication is a set of technologies for
copying and distributing data and database objects fromone database to another, and then synchronizingbetween databases to maintain consistency
Ms SQL Server Components
Trang 46• Full – Text Search lets users and applications run full-text
queries against character-based data in SQL Server tables
• The full-text index includes one or more character-basedcolumns in the table
Ms SQL Server Components
Trang 47• Notification Services is a platform for developing and
deploying applications that generate and send notifications tosubscribers The notifications generated are personalized,timely messages that can be sent to a wide range of devices,and that reflect the preferences of the subscriber
Ms SQL Server Components
Trang 48• SQL Server Management Studio
• SQL Server Configuration Manager
• SQL Server Agent
• SQL Profiler
Ms SQL Server Tools
Trang 49• SQL Server Management Studio (SSMS) is used for
configuring, managing, and administering allcomponents within Microsoft SQL Server
– This includes both script editors and graphical toolswhich work with objects and features of the server
SQL Server Management Studio
Trang 50• SQL Server Configuration Manager is a tool provided
with SQL Server 2008 for managing the servicesassociated with SQL Server and for configuring thenetwork protocols used by SQL Server
• Primarily, SQL Server Configuration Manager is used tostart, pause, resume, and stop SQL Server services and
to view or change service properties
SQL Server Configuration Manager
Trang 51• SQL Server Agent is a scheduling tool integrated into
SSMS that allows convenient definition and execution of scheduled scripts and maintenance jobs
SQL Server Agent
Trang 52• The SQL Server Profiler is a GUI interface to the SQL
Trace feature of SQL Server that captures the queriesand results flowing to and from the database engine
SQL Profiler
Trang 53Transa
• Implementation of Entry-Level ANSI ISO Standard
• Composing of 3 categories
– Data Definition Language Statements (DDL)
– Data Control Language Statements (DCL)
– Data Manipulation Language Statements (DML)
SQL Command
Trang 54SQL Command
CREATE Creates a new table, a view of a table, or other
object in databaseALTER Modifies an existing database object, such as
a table
DROP Deletes an entire table, a view of a table or
other object in the database
DDL - Data Definition Language
Trang 55UPDATE Modifies records
DELETE Deletes records
Trang 56SQL Command
DCL - Data Control Language
Command Description
GRANT Gives a privilege to user
REVOKE Takes back privileges granted from user
Trang 57Evolution of SQL Server
SQL Server 7.0
SQL Server 2005
SQL Server 2000
Realibility & Security Integrated Business Intelligence
Performance and Scalability
Automatic Tuning
• Reliability and scalability advancements
• Deep XML support
• Data warehousing
• SQL Server CE
• 64 bit support
• Re-architecture
of relational server
• First to include OLAP in
• Programmability advancements
• End-to-end business intelligence
• Manageability
• Support for multiple types of data
SQL Server 2008
• Secure trusted platform for data
• Productive policy-based management
• Optimized and predictable system performance
• Dynamic development
• Beyond relational data
• Pervasive Business Insight
SQL Server Editions
Trang 58SQL Server 2008 Standard Edition
• This is the version intended for the masses to medium-sized systems who don’t require the performance, scalability, and availability provided by Enterprise Edition.
SQL Server 2008 Enterprise Edition
• Provides the most scalability and availability of all editions and
is intended for systems that require high performance and availability, such as large-volume websites, data warehouses, and high-throughput online transaction processing (OLTP) systems.
Other SQL Server 2008 Editions
• The Standard and Enterprise Editions of SQL Server 2008 are
SQL SERVER 2008 R2 EDITIONS.