Document Details

IncredibleRetinalite2381

Uploaded by IncredibleRetinalite2381

University of Cape Town (UCT)

Tags

database design database architecture .NET database systems

Summary

These lecture notes cover different aspects of database systems, including layered architecture, component design, and the use of ADO.NET.

Full Transcript

DATABASES Week 4 - Tuesday Lecture LAYERED ARCHITECTURE VARIOUS LAYERS IN THE ARCHITECTURE There are four layers we would like to look into. Presentation responsible for handling all user interface and browser communication logic, Exposed to the end user Application layers ca...

DATABASES Week 4 - Tuesday Lecture LAYERED ARCHITECTURE VARIOUS LAYERS IN THE ARCHITECTURE There are four layers we would like to look into. Presentation responsible for handling all user interface and browser communication logic, Exposed to the end user Application layers can also make it easier to swap out implementations for testing purposes. Instead of having to write tests that operate against the real data layer or UI layer of the application, these layers can be replaced at test time with fake implementations that provide known responses to requests. This typically makes tests much easier to write and much faster to run when compared to running tests against the application's real infrastructure VARIOUS LAYERS IN THE ARCHITECTURE Application logic responsible for executing specific business rules associated with the request the application layer is an excellent way to separate interfacing layers such as presentation and domain. In doing so, the application layer contributes immensely to the clarity of the entire design. The application layer is the additional layer that reports to the presentation and orchestrates any further business action. The application layer is where you orchestrate the implementation of use- cases. In the logic layer, classes decide what information they need in order to solve their assigned problems, request that information from the accessor layer, manipulate that information as required, and return the ultimate results to the presentation layer for formatting. VARIOUS LAYERS IN THE ARCHITECTURE Domain hosts the entire business logic that is not specific to one or more use-cases. Consists of a model (known as the domain model) and possibly a family of services. The nature of the model can vary. Most of the time, it is an entity-relationship model, but it can be made of functions too. Entities in the model are expected to expose both data and behavior. Domain services are pieces of domain logic that, for some reason, don’t fit into any of the existing entities. A domain service is a class, and it groups logically related behaviors that typically operate on multiple domain entities. A domain service often also requires access to the infrastructure layer for read/write operations. The ultimate goal of a domain model is to implement the ubiquitous language and express the actions that business processes require. In this regard, exposing some behavior tends to be more relevant than holding some data. Database /infrastructure The infrastructure layer is anything related to using concrete technologies The most prominent component of the infrastructure layer is the persistence layer— data access layer The persistence layer knows how to read and/or save data. IMPLEMENTING THE LAYERED ARCHITECTURE We will use the separation of concern principle + encapsulation + the other three pillars that come with OOP. Presentation layer We will have the GUI here - for the various controls required Boundary Classes - responsible for presenting information to the user and interpreting user commands. Application logic We will have control classes. These classes will coordinate the application activity. It doesn't contain any business logic. It does not hold the state of business objects, but it can hold the state of an application task's progress. Domain layer We will have entity classes The classes will contain information about the business domain - Information about the business use case and the business rules. Domain objects encapsulate the state and behaviour of business entities. Database We will have the LocalDB with the various entities - already set up in Workshop 4 The data source here ACTIVEX DATA OBJECTS (ADO) A set of classes that expose data access services to the.NET programmer. A programming interface to access data in a database. Provides consistent access to data sources such as Microsoft® SQL Server™, as well as data sources exposed through OLE DB and XML. Data-sharing consumer applications can use ADO.NET to connect to these data sources and retrieve, manipulate, and update data. Provides a rich set of components for creating distributed, data- sharing applications. It is an integral part of the.NET Framework, providing access to relational data, XML, and application data. Supports a variety of development needs, including the creation of front-end database clients and middle-tier business objects used by applications, tools, languages, or Internet browsers. ADO.NET COMPONENTS Data providers: a set of components, such as Connection Dataset Objects COPY Disconnected from data source Can be populated with data from many sources A DataSet represents an in-memory database A DataSet is a set of DataTable objects A DataAdapter is used to retrieve data from a data source and populate tables within a DataSet. resolves changes made to the DataSet back to the data source. It uses the Connection object of the.NET Framework data provider to connect to a data source, It uses Command objects to retrieve data from and resolve changes to the data source NAMESPACES Definition A namespace can be seen as a container for some classes in much the same way that a folder on your file system contains files. Namespaces are C# program elements designed to help you organize your programs and assist in avoiding name clashes between two sets of code. For more on namespaces, see Namespaces Namespaces required with working with databases The System.Data namespace provides access to classes that represent the ADO.NET architecture that lets you build components that efficiently manage data from multiple data sources. The Sqlconnection class represents an open connection to a SQL Server database. It is used together with SqlDataAdapter and SqlCommand to increase performance when connecting to a Microsoft SQL Server database. For more, see the SqlConnectionClass File NAMESPACES SqlCommand Class The SqlCommand class is at the heart of the System.SqlClient namespace. It is used to execute operations on a database and retrieve data (CRUD). In the database programming, there are four basic and essential operations: create, read, update, and delete. These operations in database programming are called CRUD operations. CRUD is an acronym of the CREATE, READ, UPDATE and DELETE words. CREATE – insert row/rows to table. READ – read (select) row/rows from a table. UPDATE – edit row/rows in the table. DELETE – delete row/rows in the table. In short: a SqlCommand object allows you to specify what type of interaction you want to perform with a database. For example, you can do select, insert, modify, and delete commands on rows of data in a database table. See the Properties and Methods of the SqlCommand Class here. For more information read the attached file SqlCommandObjectFile NAMESPACES The System.Data.SqlClient namespace is the.NET Data Provider for SQL Server. contains the provider-specific ADO.NET objects used to connect to a SQL Server 7 or SQL Server 2000 database, execute a command, and transfer information to and from a DataSet. Interacts with SQL Server to allow the development of data-driven applications. It creates database connections with SqlConnection. It inserts data with SqlCommand. Handles rows with SqlDataReader.  A database is made up of a collection of tables that stores a specific set of structured data.  A table contains a collection of rows/tuples and column/ attributes  Each column/ attributes in the table is designed to store a certain type of information, for example, dates, names, dollar amounts, and numbers. DATABASE  For more, please visit INF2007 resources or your previous database related course.  One way to communicate with a relational database that lets you define, query, modify, and control the data is by using the SQL (Structured Query Language)  SQL consists of various command languages such as:  Data Definition Language (DDL) which are SQL commands that can be used to define the database schema..... create and modify the structure of database DATABASE AND THE objects in the database.  Examples of DDL commands include: STRUCTURED QUERY  CREATE – is used to create the database or its objects (like table, index, function, views, store procedure LANGUAGE and triggers).  DROP – is used to delete objects from the database.  ALTER-is used to alter the structure of the database.  A schema is the collection of multiple database objects, which are known as schema objects. Examples include:  a Table - to store data;  a View - to project data in a desired format from one or more tables  SQL consists of various command languages such as: DATABASE AND THE  Data Manipulation Language (DML) - a vocabulary used to retrieve and work with data in SQL Server and SQL STRUCTURED QUERY Database. Examples include  INSERT – is used to insert data into a table. LANGUAGE  UPDATE – is used to update existing data within a table.  DELETE – is used to delete records from a database table.  As a database, we will use the LocalDB:  LocalDB can act as an embedded database for a small application  LocalDB is a developer oriented, on-demand managed instance of the SQL Server engine that can be turned on DATABASE AND THE automatically when needed and turned off when not in use. STRUCTURED QUERY  It requires no configuration to run and allows for quick access to a database engine without the overhead of LANGUAGE managing and installing a full SQL Server instance.  LocalDB utilizes the minimal amount of files needed to achieve all of this.  Having the database access stay local greatly reduces the complexity for developing and testing applications with a SQL Server backend.

Use Quizgecko on...
Browser
Browser