SlideShare ist ein Scribd-Unternehmen logo
1 von 61
Advanced Programming
Methodology in C# -
Database
Introduction
My Profile
• Mr. Nhean Chenda
• Tel : 017 71 86 71
     016 71 86 71
• Personal E-Mail: nchenda@yahoo.com
• Position : Software Project Manager
• Company : Biztools Enterprise Solution
  Technologies Co., Ltd.
Educations
• NU BSc in Computer Information (Batch 7 -
  2006)
• NU MBA (Batch 19 – 2012)
Skills
• C#
• OOP
• Crystal Report, Report Sharp Shooter
• SQL Server, T-SQL Programming
• Web Service, XML
• TFS Administration
• Configuration Management
Our Study
• Attendance 5%
  • But not come to loud
• Mid-term 15%
  • Theory and simply code
  • You can do it if you understand software and
    programming
  • Can open the book, laptop, internet, … to answer
  • DO NOT ask other
• Assignment + Homework 20% (4 per group)
• Semester Exam 60%
Introduce Yourself &
What did you know
about Programming
and Database ?
This Course
• Purpose: You will
  • Understand the more detail of C# with Database
  • Have ability to develop .NET applications with
    Visual Studio with SQL Server Database
• Requirement
  • Logic
  • Try bit harder
  • Understanding of C#
  • Database
This Course              (2)

• The first step to be a programmer with
  .NET Technology
• Can be
  • Software Developer
  • Web Developer
  • Mobile Developer in Windows Phone and
   Android
Setup Your PC
• Visual Studio 2010
• Microsoft SQL Server 2008 Express R2
• If you have low capacity PC you can setup
  Visual Studio 2008
Note
• Visual Studio 2010 can create project with
  .NET 4.0 or lower
• Visual Studio 2008 can create project with
  .NET 3.5 or lower
Database
What is Database?
A database is a collection of information that is
organized so that it can easily be
accessed, managed, and updated. In one
view, databases can be classified according to
types of content: bibliographic, full-
text, numeric, and images.
What is Database?
(Cont.)
In computing, databases are sometimes classified
according to their organizational approach. The most
prevalent approach is the relational database, a tabular
database in which data is defined so that it can be
reorganized and accessed in a number of different ways.
A distributed database is one that can be dispersed or
replicated among different points in a network. An
object-oriented programming database is one that is
congruent with the data defined in object classes and
subclasses.
What is Database?
(Cont.)
Computer databases typically contain
aggregations of data records or files, such as
sales transactions, product catalogs and
inventories, and customer profiles. Typically, a
database manager provides users the
capabilities of controlling read/write
access, specifying report generation, and
analyzing usage.
What is Database?
(Cont.)
Databases and database managers are prevalent in
large mainframe systems, but are also present in
smaller distributed workstation and mid-range systems
such as the AS/400 and on personal computers. SQL
(Structured Query Language) is a standard language for
making interactive queries from and updating a
database such as IBM's DB2, Microsoft's SQL
Server, and database products from Oracle, Sybase, and
Computer Associates.
DBMS
A Database Management System (DBMS) is a set of
programs that enables storing, modifying, and
extracting information from a database, it also
provides users with tools to
add, delete, access, modify, and analyze data stored
in one location. A group can access the data by using
query and reporting tools that are part of the DBMS
or by using application programs specifically written
to access the data.
DBMS (Con.t)
DBMS’s also provide the method for maintaining
the integrity of stored data, running security and
users access, and recovering information if the
system fails.
List of DBMS
 • MS SQL Server (Microsoft)
 •   MS Access (Microsoft)
 • Oracle (Oracle)
 • My SQL (Oracle)
 •   DB2 (IBM)
 •   Sybase (SAP)
Data Access
What is Data Access?
The main goal of all APIs is to provide universal data access by
means of having a single code base for accessing data from
any source, from any language.
Having universal data access is important for four reasons:
1. Developers can easily work on applications targeting
    different data stores.
2. Developers can have a common framework for data
    access when switching between programming languages.
3. Developers are more easily write a single application that
    can be deployed against multiple data stores.
4. It provides a level of abstraction between the application
    and direct communication to the database to simplify the
    code the average developer needs to write.
What is Data Access? (Cont.)
At first, there were no common interfaces for accessing
data. Each data provider exposed an API or other
means of accessing its data. The developer only had to
be familiar with the API of the data provider used.
When companies switched to a new database
system, any knowledge of how to use the old system
became worthless and the developer had to learn a
new system from scratch. Something needed to be
done to standardize the way in which data was
retrieved from various sources.
History of Data Access
Following is a short history of the evolution of
Microsoft Data Access APIs in four parts :
1. ODBC, DAO, RDO, ODBCDirect
2. OLEDB, ADO
3. ADO.NET
4. ADO.NET Entities, LINQ
ODBC, DAO, RDO, OD
     BCDirect
ODBC
Open Database Connectivity (ODBC)
helped address the problem of needing to
know the details of each DBMS used. ODBC
provides a single interface for accessing a
number of database systems. To
accomplish this, ODBC provides a driver
model for accessing data. Any database
provider can write a driver for ODBC to
access data from their database system.
ODBC (Cont.)
This enables developers to access that
database through the ODBC drivers instead of
talking directly to the database system. For
data sources such as files, the ODBC driver
plays the role of the engine, providing direct
access to the data source. In cases where the
ODBC driver needs to connect to a database
server, the ODBC driver typically acts as a
wrapper around the API exposed by the
database server.
ODBC (Cont.)
ODBC was a huge leap forward and helped to
greatly simplify database-driven application
development. It does have some shortfalls, though.
• First, it is only capable of supporting relational
   data. If you need to access a hierarchical data
   source such as LDAP, or semi-structured
   data, ODBC can’t help you.
• Second, it can only handle SQL statements, and
   the result must be represent able in the form of
   rows and columns.
DAO
With the release of Visual Basic 2.0, developers were
introduced to a new method for accessing data, known
as Data Access Objects (DAO). This was Microsoft’s first
attempt to create a data consumer API.

DAO was based on the JET engine, which was largely
designed to help developers take advantage of the
desktop database application Microsoft was about to
release, Microsoft Access. It served to provide another
layer of abstraction between the application and data
access, making the developer’s task simpler.
DAO (Cont.)
With release of DAO 1.0, which supported direct
communication with Microsoft Access databases
without using ODBC.

The main problem with DAO is that it can only talk
to the JET engine. The JET engine then
communicates with ODBC to retrieve the data.
Going through this extra translation layer adds
unnecessary overhead and makes accessing data
through DAO slow
DAO (Cont.)
RDO
Remote Data Objects (RDO) was
Microsoft’s solution to the slow
performance created by DAO. For talking
to databases other than Microsoft
Access, RDO did not use the JET engine
like DAO; instead, it communicated
directly with the ODBC layer.
RDO (Cont.)
Removing the JET engine from the call
stack greatly improved performance to
ODBC data sources! The JET engine was
only used when accessing a Microsoft
Access Database. In addition, RDO had
the capability to use client-side cursors
to navigate the records, as opposed to
the server-side cursor requirements of
DAO.
RDO (Cont.)
This greatly reduced the load on the database
server, enabling not only the application to
perform better, but also the databases on which
that application was dependant.
RDO (Cont.)
RDO was primarily targeted toward larger, commercial
customers, many of whom avoided DAO due to the performance
issues. Instead of RDO replacing DAO, they largely co-existed. This
resulted for several reasons: First, users who developed smaller
applications, where performance wasn’t as critical, didn’t want to
take the time to switch over to the new API. Second, RDO was
originally only released with the Enterprise Edition of Visual Basic, so
some developers didn’t have a choice. Third, with the release of
ODBCDirect, a DAO add-on that routed the ODBC requests through
RDO instead of the JET engine, the performance gap between the
two became much smaller. Finally, it wasn’t long after the release of
RDO that Microsoft’s next universal access API was released.
RDO (Cont.)
OLE DB, ADO
OLE DB
Object Linking and Embedding Database (OLE-DB)
was the next big step forward in data providers, and
it is still widely used today. With OLE-DB, Microsoft
applied the knowledge learned from developing
ODBC to provide a better data access model. OLE-
DB marked Microsoft’s move to a COM-based
API, which made it easily consumable by most
programming languages, and the migration to a 32-
bit OS with the release of Windows 95.
OLE DB (Cont.)
ADO
Microsoft introduced ActiveX Data Objects (ADO)
primarily to provide a higher-level API for working with
OLE-DB. With this release, Microsoft took many of the
lessons from the past to build a lighter, more
efficient, and more universal data access API. Unlike
RDO, ADO was initially promoted as a replacement for
both DAO and RDO. At the time of its release, it (along
with OLE-DB) was widely believed to be a universal
solution for accessing any type of data—from databases
to e-mail, flat text files, and spreadsheets.
ADO (Cont.)
ADO was primarily released to complement OLE-DB;
however, ADO was not limited to just communicating with OLE-
DB data sources. ADO introduced the provider model, which
enabled software vendors to create their own providers
relatively easily, which could then be used by ADO to
communicate with a given vendor’s data source and implement
many of the optimizations specific to that data source. The ODBC
provider that shipped with ADO was one example of this. When
a developer connected to an ODBC data source, ADO would
communicate through the ODBC provider instead of through
OLE-DB. More direct communication to the data source resulted
in better performance and an easily extensible framework.
ADO (Cont.)
In addition to being a cleaner object
model, ADO also offered a wider feature set to
help lure developers away from DAO and RDO.
These included the following:
❑ Batch Updating—For the first time, users
enjoyed the capability to make changes to an
entire recordset in memory and then persist
these changes back to the database by using the
UpdateBatch command.
ADO (Cont.)
❑ Disconnected Data Access—Although this wasn’t
available in the original release, subsequent releases
offered the capability to work with data in a
disconnected state, which greatly reduced the load
placed on database servers.
❑ Multiple Recordsets—ADO provided the capability
to execute a query that returns multiple recordsets
and work with all of them in memory. This feature
wasn’t even available in ADO.NET until this
release, now known as Multiple Active Result Sets
(MARS).
ADO (Cont.)
ADO.NET
ADO.NET
With the release of the .NET
Framework, Microsoft introduced a new data
access model, called ADO.NET. The ActiveX Data
Object acronym was no longer relevant, as
ADO.NET was not ActiveX, but Microsoft kept
the acronym due to the huge success of ADO. In
reality, it’s an entirely new data access model
written in the .NET Framework.
ADO.NET (Cont.)
ADO.NET supports communication to data sources
through both ODBC and OLE-DB, but it also offers another
option of using database-specific data providers. These
data providers offer greater performance by being able to
take advantage of data-source-specific optimizations. By
using custom code for the data source instead of the
generic ODBC and OLE-DB code, some of the overhead is
also avoided. The original release of ADO.NET included a
SQL provider and an OLE-DB provider, with the ODBC and
Oracle providers being introduced later. Many vendors
have also written providers for their databases since.
ADO.NET (Cont.)
With ADO.NET, the days of the recordset and cursor are
gone. The model is entirely new, and consists of five basic
objects:
❑ Connection—The Connection object is responsible for
establishing and maintaining the connection to the data
source, along with any connection-specific information.
❑ Command—The Command object stores the query
that is to be sent to the data source, and any applicable
parameters.
❑ DataReader—The DataReader object provides
fast, forward-only reading capability to quickly loop
through the records.
ADO.NET (Cont.)
❑ DataSet—The DataSet object, along with its child
objects, is what really makes ADO.NET unique. It provides a
storage mechanism for disconnected data. The DataSet
never communicates with any data source and is totally
unaware of the source of the data used to populate it. The
best way to think of it is as an in-memory repository to
store data that has been retrieved.
❑ DataAdapter—The DataAdapter object is what bridges
the gap between the DataSet and the data source. The
DataAdapter is responsible for retrieving the data from the
Command object and populating the DataSet with the data
returned. The DataAdapter is also responsible for persisting
changes to the DataSet back to the data source.
ADO.NET (Cont.)
ADO.NET made several huge leaps forward.
Arguably, the greatest was the introduction of truly
disconnected data access. Maintaining a connection
to a database server such as MS SQL Server is an
expensive operation. The server allocates resources to
each connection, so it’s important to limit the number
of simultaneous connections. By disconnecting from
the server as soon as the data is retrieved, instead of
when the code is done working with that data, that
connection becomes available for another
process, making the application much more scalable.
ADO.NET (Cont.)
Another feature of ADO.NET that greatly improved
performance was the introduction of connection
pooling. Not only is maintaining a connection to the
database an expensive operation, but creating and
destroying that connection is also very expensive.
Connection pooling cuts down on this. When a
connection is destroyed in code, the Framework
keeps it open in a pool. When the next process
comes around that needs a connection with the
same credentials, it retrieves it from the
pool, instead of creating a new one.
ADO.NET (Cont.)
Several other advantages are made possible
by the DataSet object. The DataSet object
stores the data as XML, which makes it easy to
filter and sort the data in memory. It also
makes it easy to convert the data to other
formats, as well as easily persist it to another
data store and restore it again.
ADO.NET (Cont.)
ADO.NET
Entities, LINQ
ADO.NET Entities
ADO.NET Entities builds upon our mutual investment in
ADO.NET by adding the ability to write applications
against a rich conceptual "Entity Data Model"
schema, rather than a flat relational database schema.
The Entity Data Model (EDM) extends the relational data
model with Entity-Relationship (ER) constructs for
modeling real-world concepts such as Inheritance (cars
and trucks are vehicles), Relationships (customers have
orders), and complex members (street, city, region, and
postal code composed as a single "address" property
within a customer).
ADO.NET Entities (Cont.)
An extended-SQL grammar called "Entity SQL"
allows you to directly query your conceptual
schema, leveraging inheritance, accessing complex
members, and navigating relationships. In many
cases, building these concepts into the conceptual
schema and query language removes the need for
complex joins, unions, and subqueries to do
conceptually simple operations.
LINQ
"LINQ" stands for "Language INtegrated Query". As the
name implies, LINQ integrates query concepts directly
into the programming languages, enabling data access
code to be type-checked by the language complier, and
developer tools like Intellisense to make it easier for
developers to write queries. This, along with higher
level conceptual models (like Entities), contributes to
reducing the impedance mismatch between
applications and data.
LINQ (Cont.)
LINQ is supported as a first-class citizen within the ADO.NET
Entity Framework through "LINQ to Entities". LINQ to
Entities is part of the Object Services layer which enables
you to build queries through strongly typed language
expressions and built-in query comprehensions (in C# and
VB) as well as textual Entity SQL statements. This means
that the same conceptual client views are available through
existing ADO.NET provider programming patterns or
through consuming Object Services using either ad-hoc
textual queries or integrated language queries.
ORM
ORM
Object-Relational Mapping (ORM, O/RM, and O/R
Mapping) in computer software is a programming
technique for converting data between incompatible
type system in object-oriented programming
languages. This creates, in effect, a “virtual object
database” that can be used from within the
programming language. Data management tasks in
object-oriented (OO) programming are typically
implemented by manipulating objects that are almost
always non-scalar values.
ORM (Cont.)
For example, consider an address book entry that
represents a s single person along with zero or
more phone numbers and zero or more address.
This could be modeled in an object-oriented
implementation by a “Person object” with
attributes/fields to hold each data item that the
entry comprises: the person’s name, a list of
phone numbers, and a list of addresses.
ORM (Cont.)
The list of phone numbers would itself contain
“PhoneNumber objects” and so on. The address
book entry is treated as a single object by the
programming language (it can be referenced by a
single variable containing a pointer to the
object, for instance). Various methods can be
associated with the object, such as a method to
return the preferred phone number, the home
address and so on.
Summary
What you learn from this chapter are:
• Database
• DBMS
• Data Access
• Type of Data Access are using with current .NET
  Framework (ADO.NET and LINQ)
• ORM

Weitere ähnliche Inhalte

Was ist angesagt?

PHP Roadshow - MySQL Database Essentials
PHP Roadshow - MySQL Database EssentialsPHP Roadshow - MySQL Database Essentials
PHP Roadshow - MySQL Database EssentialsCherrie Ann Domingo
 
Rdbms
RdbmsRdbms
Rdbmsrdbms
 
Ch 1 D B Environment
Ch 1  D B  EnvironmentCh 1  D B  Environment
Ch 1 D B Environmentguest8fdbdd
 
Function
FunctionFunction
Functionrey501
 
Data & database administration hoffer
Data & database administration   hofferData & database administration   hoffer
Data & database administration hofferMohd Arif
 
Data and database administration(database)
Data and database administration(database)Data and database administration(database)
Data and database administration(database)welcometofacebook
 
Database administrator
Database administratorDatabase administrator
Database administratorTech_MX
 
Mi0034 – database management system
Mi0034 – database management systemMi0034 – database management system
Mi0034 – database management systemsmumbahelp
 
Chap 4 hardware & software
Chap 4 hardware & softwareChap 4 hardware & software
Chap 4 hardware & softwareUMaine
 
Database Performance Management in Cloud
Database Performance Management in CloudDatabase Performance Management in Cloud
Database Performance Management in CloudDr. Amarjeet Singh
 
Ans mi0034-database management system-sda-2012-ii
Ans mi0034-database management system-sda-2012-iiAns mi0034-database management system-sda-2012-ii
Ans mi0034-database management system-sda-2012-iizafarishtiaq
 
Database design, implementation, and management -chapter04
Database design, implementation, and management -chapter04Database design, implementation, and management -chapter04
Database design, implementation, and management -chapter04Beni Krisbiantoro
 

Was ist angesagt? (19)

PHP Roadshow - MySQL Database Essentials
PHP Roadshow - MySQL Database EssentialsPHP Roadshow - MySQL Database Essentials
PHP Roadshow - MySQL Database Essentials
 
Rdbms
RdbmsRdbms
Rdbms
 
oracle intro
oracle introoracle intro
oracle intro
 
Ch 1 D B Environment
Ch 1  D B  EnvironmentCh 1  D B  Environment
Ch 1 D B Environment
 
2ndlec.database
2ndlec.database2ndlec.database
2ndlec.database
 
Function
FunctionFunction
Function
 
Data & database administration hoffer
Data & database administration   hofferData & database administration   hoffer
Data & database administration hoffer
 
Chapter2
Chapter2Chapter2
Chapter2
 
27 fcs157al1 (1)
27 fcs157al1 (1)27 fcs157al1 (1)
27 fcs157al1 (1)
 
Data and database administration(database)
Data and database administration(database)Data and database administration(database)
Data and database administration(database)
 
Chapter 5
Chapter 5Chapter 5
Chapter 5
 
Database administrator
Database administratorDatabase administrator
Database administrator
 
Mi0034 – database management system
Mi0034 – database management systemMi0034 – database management system
Mi0034 – database management system
 
10g sql e book
10g sql e book10g sql e book
10g sql e book
 
Chap 4 hardware & software
Chap 4 hardware & softwareChap 4 hardware & software
Chap 4 hardware & software
 
Database Performance Management in Cloud
Database Performance Management in CloudDatabase Performance Management in Cloud
Database Performance Management in Cloud
 
DDBMS
DDBMSDDBMS
DDBMS
 
Ans mi0034-database management system-sda-2012-ii
Ans mi0034-database management system-sda-2012-iiAns mi0034-database management system-sda-2012-ii
Ans mi0034-database management system-sda-2012-ii
 
Database design, implementation, and management -chapter04
Database design, implementation, and management -chapter04Database design, implementation, and management -chapter04
Database design, implementation, and management -chapter04
 

Ähnlich wie 1 introduction

INF3703 - Chapter 17 Database Connectivity Web Technologies
INF3703 - Chapter 17 Database Connectivity Web TechnologiesINF3703 - Chapter 17 Database Connectivity Web Technologies
INF3703 - Chapter 17 Database Connectivity Web Technologiesbloeyyy
 
Data Centric Composites and mashups In SharePoint 2010
Data Centric Composites and mashups In SharePoint 2010Data Centric Composites and mashups In SharePoint 2010
Data Centric Composites and mashups In SharePoint 2010Ayman El-Hattab
 
Utilized Code Gen To Save Our Efforts In Sap Integration
Utilized Code Gen To Save Our Efforts In Sap IntegrationUtilized Code Gen To Save Our Efforts In Sap Integration
Utilized Code Gen To Save Our Efforts In Sap IntegrationGuo Albert
 
Myth Busters II: BI Tools and Data Virtualization are Interchangeable
Myth Busters II: BI Tools and Data Virtualization are InterchangeableMyth Busters II: BI Tools and Data Virtualization are Interchangeable
Myth Busters II: BI Tools and Data Virtualization are InterchangeableDenodo
 
A ____________ is a disconnected, memory-resident representation o.docx
A ____________ is a disconnected, memory-resident representation o.docxA ____________ is a disconnected, memory-resident representation o.docx
A ____________ is a disconnected, memory-resident representation o.docxransayo
 
Window programming
Window programmingWindow programming
Window programmingPooja Rathee
 
Accessing data within VB Applications
Accessing data within VB ApplicationsAccessing data within VB Applications
Accessing data within VB Applicationsrobertbenard
 
Doing data visualizations with tableau
Doing data visualizations with tableauDoing data visualizations with tableau
Doing data visualizations with tableauRay Schwartz
 
Cookbook for Building An App
Cookbook for Building An AppCookbook for Building An App
Cookbook for Building An AppManish Jain
 
System i - DDL vs DDS Presentation
System i - DDL vs DDS PresentationSystem i - DDL vs DDS Presentation
System i - DDL vs DDS PresentationChuck Walker
 
Developing multithreaded database application using java tools and oracle dat...
Developing multithreaded database application using java tools and oracle dat...Developing multithreaded database application using java tools and oracle dat...
Developing multithreaded database application using java tools and oracle dat...csandit
 

Ähnlich wie 1 introduction (20)

INF3703 - Chapter 17 Database Connectivity Web Technologies
INF3703 - Chapter 17 Database Connectivity Web TechnologiesINF3703 - Chapter 17 Database Connectivity Web Technologies
INF3703 - Chapter 17 Database Connectivity Web Technologies
 
Project seminar
Project seminarProject seminar
Project seminar
 
Access & SharePoint
Access & SharePointAccess & SharePoint
Access & SharePoint
 
Microsoft data access components
Microsoft data access componentsMicrosoft data access components
Microsoft data access components
 
Data Centric Composites and mashups In SharePoint 2010
Data Centric Composites and mashups In SharePoint 2010Data Centric Composites and mashups In SharePoint 2010
Data Centric Composites and mashups In SharePoint 2010
 
Utilized Code Gen To Save Our Efforts In Sap Integration
Utilized Code Gen To Save Our Efforts In Sap IntegrationUtilized Code Gen To Save Our Efforts In Sap Integration
Utilized Code Gen To Save Our Efforts In Sap Integration
 
Myth Busters II: BI Tools and Data Virtualization are Interchangeable
Myth Busters II: BI Tools and Data Virtualization are InterchangeableMyth Busters II: BI Tools and Data Virtualization are Interchangeable
Myth Busters II: BI Tools and Data Virtualization are Interchangeable
 
Bo df b_layer
Bo df b_layerBo df b_layer
Bo df b_layer
 
Final project cafe coffe
Final project cafe coffeFinal project cafe coffe
Final project cafe coffe
 
Sap BusinessObjects 4
Sap BusinessObjects 4Sap BusinessObjects 4
Sap BusinessObjects 4
 
A ____________ is a disconnected, memory-resident representation o.docx
A ____________ is a disconnected, memory-resident representation o.docxA ____________ is a disconnected, memory-resident representation o.docx
A ____________ is a disconnected, memory-resident representation o.docx
 
Resume_Ravichandra Thota
Resume_Ravichandra ThotaResume_Ravichandra Thota
Resume_Ravichandra Thota
 
12363 database certification
12363 database certification12363 database certification
12363 database certification
 
Mrithyunjaya_V_Sarangmath
Mrithyunjaya_V_SarangmathMrithyunjaya_V_Sarangmath
Mrithyunjaya_V_Sarangmath
 
Window programming
Window programmingWindow programming
Window programming
 
Accessing data within VB Applications
Accessing data within VB ApplicationsAccessing data within VB Applications
Accessing data within VB Applications
 
Doing data visualizations with tableau
Doing data visualizations with tableauDoing data visualizations with tableau
Doing data visualizations with tableau
 
Cookbook for Building An App
Cookbook for Building An AppCookbook for Building An App
Cookbook for Building An App
 
System i - DDL vs DDS Presentation
System i - DDL vs DDS PresentationSystem i - DDL vs DDS Presentation
System i - DDL vs DDS Presentation
 
Developing multithreaded database application using java tools and oracle dat...
Developing multithreaded database application using java tools and oracle dat...Developing multithreaded database application using java tools and oracle dat...
Developing multithreaded database application using java tools and oracle dat...
 

Mehr von Ngeam Soly

សន្ធិ​សញ្ញា​កំណត់​ព្រំដែន កម្ពុជា-វៀតណាម
សន្ធិ​សញ្ញា​កំណត់​ព្រំដែន កម្ពុជា-វៀតណាមសន្ធិ​សញ្ញា​កំណត់​ព្រំដែន កម្ពុជា-វៀតណាម
សន្ធិ​សញ្ញា​កំណត់​ព្រំដែន កម្ពុជា-វៀតណាមNgeam Soly
 
អត្ថបទគោល៖ ការងារ​បោះ​បង្គោល​ខណ្ឌ​សីមា​ព្រំ​ដែន​​គោក និង​​ការ​​កំណត់​ព្រំដែន​...
អត្ថបទគោល៖ ការងារ​បោះ​បង្គោល​ខណ្ឌ​សីមា​ព្រំ​ដែន​​គោក និង​​ការ​​កំណត់​ព្រំដែន​...អត្ថបទគោល៖ ការងារ​បោះ​បង្គោល​ខណ្ឌ​សីមា​ព្រំ​ដែន​​គោក និង​​ការ​​កំណត់​ព្រំដែន​...
អត្ថបទគោល៖ ការងារ​បោះ​បង្គោល​ខណ្ឌ​សីមា​ព្រំ​ដែន​​គោក និង​​ការ​​កំណត់​ព្រំដែន​...Ngeam Soly
 
មេរៀនៈ Data Structure and Algorithm in C/C++
មេរៀនៈ Data Structure and Algorithm in C/C++មេរៀនៈ Data Structure and Algorithm in C/C++
មេរៀនៈ Data Structure and Algorithm in C/C++Ngeam Soly
 
Chapter 3: ado.net
Chapter 3: ado.netChapter 3: ado.net
Chapter 3: ado.netNgeam Soly
 
Chapter 2: Ms SQL Server
Chapter 2: Ms SQL ServerChapter 2: Ms SQL Server
Chapter 2: Ms SQL ServerNgeam Soly
 
Slide for presentation
Slide for presentation Slide for presentation
Slide for presentation Ngeam Soly
 
Accounting assingment year ii
Accounting assingment year iiAccounting assingment year ii
Accounting assingment year iiNgeam Soly
 
Account's Assignment
Account's AssignmentAccount's Assignment
Account's AssignmentNgeam Soly
 
Chapter5: Usage of Build-In Functions or Methods
Chapter5: Usage of Build-In Functions or MethodsChapter5: Usage of Build-In Functions or Methods
Chapter5: Usage of Build-In Functions or MethodsNgeam Soly
 
Chapter3: fundamental programming
Chapter3: fundamental programmingChapter3: fundamental programming
Chapter3: fundamental programmingNgeam Soly
 

Mehr von Ngeam Soly (10)

សន្ធិ​សញ្ញា​កំណត់​ព្រំដែន កម្ពុជា-វៀតណាម
សន្ធិ​សញ្ញា​កំណត់​ព្រំដែន កម្ពុជា-វៀតណាមសន្ធិ​សញ្ញា​កំណត់​ព្រំដែន កម្ពុជា-វៀតណាម
សន្ធិ​សញ្ញា​កំណត់​ព្រំដែន កម្ពុជា-វៀតណាម
 
អត្ថបទគោល៖ ការងារ​បោះ​បង្គោល​ខណ្ឌ​សីមា​ព្រំ​ដែន​​គោក និង​​ការ​​កំណត់​ព្រំដែន​...
អត្ថបទគោល៖ ការងារ​បោះ​បង្គោល​ខណ្ឌ​សីមា​ព្រំ​ដែន​​គោក និង​​ការ​​កំណត់​ព្រំដែន​...អត្ថបទគោល៖ ការងារ​បោះ​បង្គោល​ខណ្ឌ​សីមា​ព្រំ​ដែន​​គោក និង​​ការ​​កំណត់​ព្រំដែន​...
អត្ថបទគោល៖ ការងារ​បោះ​បង្គោល​ខណ្ឌ​សីមា​ព្រំ​ដែន​​គោក និង​​ការ​​កំណត់​ព្រំដែន​...
 
មេរៀនៈ Data Structure and Algorithm in C/C++
មេរៀនៈ Data Structure and Algorithm in C/C++មេរៀនៈ Data Structure and Algorithm in C/C++
មេរៀនៈ Data Structure and Algorithm in C/C++
 
Chapter 3: ado.net
Chapter 3: ado.netChapter 3: ado.net
Chapter 3: ado.net
 
Chapter 2: Ms SQL Server
Chapter 2: Ms SQL ServerChapter 2: Ms SQL Server
Chapter 2: Ms SQL Server
 
Slide for presentation
Slide for presentation Slide for presentation
Slide for presentation
 
Accounting assingment year ii
Accounting assingment year iiAccounting assingment year ii
Accounting assingment year ii
 
Account's Assignment
Account's AssignmentAccount's Assignment
Account's Assignment
 
Chapter5: Usage of Build-In Functions or Methods
Chapter5: Usage of Build-In Functions or MethodsChapter5: Usage of Build-In Functions or Methods
Chapter5: Usage of Build-In Functions or Methods
 
Chapter3: fundamental programming
Chapter3: fundamental programmingChapter3: fundamental programming
Chapter3: fundamental programming
 

1 introduction

  • 3. My Profile • Mr. Nhean Chenda • Tel : 017 71 86 71 016 71 86 71 • Personal E-Mail: nchenda@yahoo.com • Position : Software Project Manager • Company : Biztools Enterprise Solution Technologies Co., Ltd.
  • 4. Educations • NU BSc in Computer Information (Batch 7 - 2006) • NU MBA (Batch 19 – 2012)
  • 5. Skills • C# • OOP • Crystal Report, Report Sharp Shooter • SQL Server, T-SQL Programming • Web Service, XML • TFS Administration • Configuration Management
  • 6. Our Study • Attendance 5% • But not come to loud • Mid-term 15% • Theory and simply code • You can do it if you understand software and programming • Can open the book, laptop, internet, … to answer • DO NOT ask other • Assignment + Homework 20% (4 per group) • Semester Exam 60%
  • 7. Introduce Yourself & What did you know about Programming and Database ?
  • 8. This Course • Purpose: You will • Understand the more detail of C# with Database • Have ability to develop .NET applications with Visual Studio with SQL Server Database • Requirement • Logic • Try bit harder • Understanding of C# • Database
  • 9. This Course (2) • The first step to be a programmer with .NET Technology • Can be • Software Developer • Web Developer • Mobile Developer in Windows Phone and Android
  • 10. Setup Your PC • Visual Studio 2010 • Microsoft SQL Server 2008 Express R2 • If you have low capacity PC you can setup Visual Studio 2008 Note • Visual Studio 2010 can create project with .NET 4.0 or lower • Visual Studio 2008 can create project with .NET 3.5 or lower
  • 12. What is Database? A database is a collection of information that is organized so that it can easily be accessed, managed, and updated. In one view, databases can be classified according to types of content: bibliographic, full- text, numeric, and images.
  • 13. What is Database? (Cont.) In computing, databases are sometimes classified according to their organizational approach. The most prevalent approach is the relational database, a tabular database in which data is defined so that it can be reorganized and accessed in a number of different ways. A distributed database is one that can be dispersed or replicated among different points in a network. An object-oriented programming database is one that is congruent with the data defined in object classes and subclasses.
  • 14. What is Database? (Cont.) Computer databases typically contain aggregations of data records or files, such as sales transactions, product catalogs and inventories, and customer profiles. Typically, a database manager provides users the capabilities of controlling read/write access, specifying report generation, and analyzing usage.
  • 15. What is Database? (Cont.) Databases and database managers are prevalent in large mainframe systems, but are also present in smaller distributed workstation and mid-range systems such as the AS/400 and on personal computers. SQL (Structured Query Language) is a standard language for making interactive queries from and updating a database such as IBM's DB2, Microsoft's SQL Server, and database products from Oracle, Sybase, and Computer Associates.
  • 16. DBMS A Database Management System (DBMS) is a set of programs that enables storing, modifying, and extracting information from a database, it also provides users with tools to add, delete, access, modify, and analyze data stored in one location. A group can access the data by using query and reporting tools that are part of the DBMS or by using application programs specifically written to access the data.
  • 17. DBMS (Con.t) DBMS’s also provide the method for maintaining the integrity of stored data, running security and users access, and recovering information if the system fails.
  • 18. List of DBMS • MS SQL Server (Microsoft) • MS Access (Microsoft) • Oracle (Oracle) • My SQL (Oracle) • DB2 (IBM) • Sybase (SAP)
  • 20. What is Data Access? The main goal of all APIs is to provide universal data access by means of having a single code base for accessing data from any source, from any language. Having universal data access is important for four reasons: 1. Developers can easily work on applications targeting different data stores. 2. Developers can have a common framework for data access when switching between programming languages. 3. Developers are more easily write a single application that can be deployed against multiple data stores. 4. It provides a level of abstraction between the application and direct communication to the database to simplify the code the average developer needs to write.
  • 21. What is Data Access? (Cont.) At first, there were no common interfaces for accessing data. Each data provider exposed an API or other means of accessing its data. The developer only had to be familiar with the API of the data provider used. When companies switched to a new database system, any knowledge of how to use the old system became worthless and the developer had to learn a new system from scratch. Something needed to be done to standardize the way in which data was retrieved from various sources.
  • 22. History of Data Access Following is a short history of the evolution of Microsoft Data Access APIs in four parts : 1. ODBC, DAO, RDO, ODBCDirect 2. OLEDB, ADO 3. ADO.NET 4. ADO.NET Entities, LINQ
  • 23. ODBC, DAO, RDO, OD BCDirect
  • 24. ODBC Open Database Connectivity (ODBC) helped address the problem of needing to know the details of each DBMS used. ODBC provides a single interface for accessing a number of database systems. To accomplish this, ODBC provides a driver model for accessing data. Any database provider can write a driver for ODBC to access data from their database system.
  • 25. ODBC (Cont.) This enables developers to access that database through the ODBC drivers instead of talking directly to the database system. For data sources such as files, the ODBC driver plays the role of the engine, providing direct access to the data source. In cases where the ODBC driver needs to connect to a database server, the ODBC driver typically acts as a wrapper around the API exposed by the database server.
  • 26. ODBC (Cont.) ODBC was a huge leap forward and helped to greatly simplify database-driven application development. It does have some shortfalls, though. • First, it is only capable of supporting relational data. If you need to access a hierarchical data source such as LDAP, or semi-structured data, ODBC can’t help you. • Second, it can only handle SQL statements, and the result must be represent able in the form of rows and columns.
  • 27. DAO With the release of Visual Basic 2.0, developers were introduced to a new method for accessing data, known as Data Access Objects (DAO). This was Microsoft’s first attempt to create a data consumer API. DAO was based on the JET engine, which was largely designed to help developers take advantage of the desktop database application Microsoft was about to release, Microsoft Access. It served to provide another layer of abstraction between the application and data access, making the developer’s task simpler.
  • 28. DAO (Cont.) With release of DAO 1.0, which supported direct communication with Microsoft Access databases without using ODBC. The main problem with DAO is that it can only talk to the JET engine. The JET engine then communicates with ODBC to retrieve the data. Going through this extra translation layer adds unnecessary overhead and makes accessing data through DAO slow
  • 30. RDO Remote Data Objects (RDO) was Microsoft’s solution to the slow performance created by DAO. For talking to databases other than Microsoft Access, RDO did not use the JET engine like DAO; instead, it communicated directly with the ODBC layer.
  • 31. RDO (Cont.) Removing the JET engine from the call stack greatly improved performance to ODBC data sources! The JET engine was only used when accessing a Microsoft Access Database. In addition, RDO had the capability to use client-side cursors to navigate the records, as opposed to the server-side cursor requirements of DAO.
  • 32. RDO (Cont.) This greatly reduced the load on the database server, enabling not only the application to perform better, but also the databases on which that application was dependant.
  • 33. RDO (Cont.) RDO was primarily targeted toward larger, commercial customers, many of whom avoided DAO due to the performance issues. Instead of RDO replacing DAO, they largely co-existed. This resulted for several reasons: First, users who developed smaller applications, where performance wasn’t as critical, didn’t want to take the time to switch over to the new API. Second, RDO was originally only released with the Enterprise Edition of Visual Basic, so some developers didn’t have a choice. Third, with the release of ODBCDirect, a DAO add-on that routed the ODBC requests through RDO instead of the JET engine, the performance gap between the two became much smaller. Finally, it wasn’t long after the release of RDO that Microsoft’s next universal access API was released.
  • 36. OLE DB Object Linking and Embedding Database (OLE-DB) was the next big step forward in data providers, and it is still widely used today. With OLE-DB, Microsoft applied the knowledge learned from developing ODBC to provide a better data access model. OLE- DB marked Microsoft’s move to a COM-based API, which made it easily consumable by most programming languages, and the migration to a 32- bit OS with the release of Windows 95.
  • 38. ADO Microsoft introduced ActiveX Data Objects (ADO) primarily to provide a higher-level API for working with OLE-DB. With this release, Microsoft took many of the lessons from the past to build a lighter, more efficient, and more universal data access API. Unlike RDO, ADO was initially promoted as a replacement for both DAO and RDO. At the time of its release, it (along with OLE-DB) was widely believed to be a universal solution for accessing any type of data—from databases to e-mail, flat text files, and spreadsheets.
  • 39. ADO (Cont.) ADO was primarily released to complement OLE-DB; however, ADO was not limited to just communicating with OLE- DB data sources. ADO introduced the provider model, which enabled software vendors to create their own providers relatively easily, which could then be used by ADO to communicate with a given vendor’s data source and implement many of the optimizations specific to that data source. The ODBC provider that shipped with ADO was one example of this. When a developer connected to an ODBC data source, ADO would communicate through the ODBC provider instead of through OLE-DB. More direct communication to the data source resulted in better performance and an easily extensible framework.
  • 40. ADO (Cont.) In addition to being a cleaner object model, ADO also offered a wider feature set to help lure developers away from DAO and RDO. These included the following: ❑ Batch Updating—For the first time, users enjoyed the capability to make changes to an entire recordset in memory and then persist these changes back to the database by using the UpdateBatch command.
  • 41. ADO (Cont.) ❑ Disconnected Data Access—Although this wasn’t available in the original release, subsequent releases offered the capability to work with data in a disconnected state, which greatly reduced the load placed on database servers. ❑ Multiple Recordsets—ADO provided the capability to execute a query that returns multiple recordsets and work with all of them in memory. This feature wasn’t even available in ADO.NET until this release, now known as Multiple Active Result Sets (MARS).
  • 44. ADO.NET With the release of the .NET Framework, Microsoft introduced a new data access model, called ADO.NET. The ActiveX Data Object acronym was no longer relevant, as ADO.NET was not ActiveX, but Microsoft kept the acronym due to the huge success of ADO. In reality, it’s an entirely new data access model written in the .NET Framework.
  • 45. ADO.NET (Cont.) ADO.NET supports communication to data sources through both ODBC and OLE-DB, but it also offers another option of using database-specific data providers. These data providers offer greater performance by being able to take advantage of data-source-specific optimizations. By using custom code for the data source instead of the generic ODBC and OLE-DB code, some of the overhead is also avoided. The original release of ADO.NET included a SQL provider and an OLE-DB provider, with the ODBC and Oracle providers being introduced later. Many vendors have also written providers for their databases since.
  • 46. ADO.NET (Cont.) With ADO.NET, the days of the recordset and cursor are gone. The model is entirely new, and consists of five basic objects: ❑ Connection—The Connection object is responsible for establishing and maintaining the connection to the data source, along with any connection-specific information. ❑ Command—The Command object stores the query that is to be sent to the data source, and any applicable parameters. ❑ DataReader—The DataReader object provides fast, forward-only reading capability to quickly loop through the records.
  • 47. ADO.NET (Cont.) ❑ DataSet—The DataSet object, along with its child objects, is what really makes ADO.NET unique. It provides a storage mechanism for disconnected data. The DataSet never communicates with any data source and is totally unaware of the source of the data used to populate it. The best way to think of it is as an in-memory repository to store data that has been retrieved. ❑ DataAdapter—The DataAdapter object is what bridges the gap between the DataSet and the data source. The DataAdapter is responsible for retrieving the data from the Command object and populating the DataSet with the data returned. The DataAdapter is also responsible for persisting changes to the DataSet back to the data source.
  • 48. ADO.NET (Cont.) ADO.NET made several huge leaps forward. Arguably, the greatest was the introduction of truly disconnected data access. Maintaining a connection to a database server such as MS SQL Server is an expensive operation. The server allocates resources to each connection, so it’s important to limit the number of simultaneous connections. By disconnecting from the server as soon as the data is retrieved, instead of when the code is done working with that data, that connection becomes available for another process, making the application much more scalable.
  • 49. ADO.NET (Cont.) Another feature of ADO.NET that greatly improved performance was the introduction of connection pooling. Not only is maintaining a connection to the database an expensive operation, but creating and destroying that connection is also very expensive. Connection pooling cuts down on this. When a connection is destroyed in code, the Framework keeps it open in a pool. When the next process comes around that needs a connection with the same credentials, it retrieves it from the pool, instead of creating a new one.
  • 50. ADO.NET (Cont.) Several other advantages are made possible by the DataSet object. The DataSet object stores the data as XML, which makes it easy to filter and sort the data in memory. It also makes it easy to convert the data to other formats, as well as easily persist it to another data store and restore it again.
  • 53. ADO.NET Entities ADO.NET Entities builds upon our mutual investment in ADO.NET by adding the ability to write applications against a rich conceptual "Entity Data Model" schema, rather than a flat relational database schema. The Entity Data Model (EDM) extends the relational data model with Entity-Relationship (ER) constructs for modeling real-world concepts such as Inheritance (cars and trucks are vehicles), Relationships (customers have orders), and complex members (street, city, region, and postal code composed as a single "address" property within a customer).
  • 54. ADO.NET Entities (Cont.) An extended-SQL grammar called "Entity SQL" allows you to directly query your conceptual schema, leveraging inheritance, accessing complex members, and navigating relationships. In many cases, building these concepts into the conceptual schema and query language removes the need for complex joins, unions, and subqueries to do conceptually simple operations.
  • 55. LINQ "LINQ" stands for "Language INtegrated Query". As the name implies, LINQ integrates query concepts directly into the programming languages, enabling data access code to be type-checked by the language complier, and developer tools like Intellisense to make it easier for developers to write queries. This, along with higher level conceptual models (like Entities), contributes to reducing the impedance mismatch between applications and data.
  • 56. LINQ (Cont.) LINQ is supported as a first-class citizen within the ADO.NET Entity Framework through "LINQ to Entities". LINQ to Entities is part of the Object Services layer which enables you to build queries through strongly typed language expressions and built-in query comprehensions (in C# and VB) as well as textual Entity SQL statements. This means that the same conceptual client views are available through existing ADO.NET provider programming patterns or through consuming Object Services using either ad-hoc textual queries or integrated language queries.
  • 57. ORM
  • 58. ORM Object-Relational Mapping (ORM, O/RM, and O/R Mapping) in computer software is a programming technique for converting data between incompatible type system in object-oriented programming languages. This creates, in effect, a “virtual object database” that can be used from within the programming language. Data management tasks in object-oriented (OO) programming are typically implemented by manipulating objects that are almost always non-scalar values.
  • 59. ORM (Cont.) For example, consider an address book entry that represents a s single person along with zero or more phone numbers and zero or more address. This could be modeled in an object-oriented implementation by a “Person object” with attributes/fields to hold each data item that the entry comprises: the person’s name, a list of phone numbers, and a list of addresses.
  • 60. ORM (Cont.) The list of phone numbers would itself contain “PhoneNumber objects” and so on. The address book entry is treated as a single object by the programming language (it can be referenced by a single variable containing a pointer to the object, for instance). Various methods can be associated with the object, such as a method to return the preferred phone number, the home address and so on.
  • 61. Summary What you learn from this chapter are: • Database • DBMS • Data Access • Type of Data Access are using with current .NET Framework (ADO.NET and LINQ) • ORM