Você está na página 1de 16

Database Language

Data storage definition language (DSDL) is used to define the internal schema in the database. The mapping between between internal schema and conceptual schema is done either by DDL or DSDL. DSDL is used to define the storage structure and the access methods used by the database system. View definition language (VDL) Used to specify users views (external schema) and their mappings to the conceptual schema. Some times DDL may be used for the same. [ Data view :- logical view is used by the programmers and other is the physical view]

Database Language
Data manipulation language (DML)
Provides set of operations to support the basic data manipulation operations. Helps in communicating with DBMS. The part of DML used for data retrieval is called query language. The following manipulations can be done Retrieval of data Addition of records Deletion of records Retrieval of records sequentially in the key sequence Retrieval of records in the physically recorded sequence. Rewrite of records that have been updated. Modification of data

Database Language
Fourth-generation language (4GL) is a compact, efficient and non-procedural programming language used to improve the productivity of the DBMS. The user has to define what is to be done not how to do. 4GL has the following components
Query languages

Report generators Spreadsheets Database languages Application generators to define operations like insertion, retrieval of data and updations. High-level languages to generate application programs

SQL DML and DDL SQL can be divided into two parts: The Data Manipulation Language (DML) and the Data Definition Language (DDL). The query and update commands form the DML part of SQL: SELECT - extracts data from a database UPDATE - updates data in a database DELETE - deletes data from a database INSERT INTO - inserts new data into a database

The DDL part of SQL permits database tables to be created or deleted. It also defines indexes (keys), specifies links between tables, and imposes constraints between tables. The most important DDL statements in SQL are: CREATE DATABASE - creates a new database ALTER DATABASE - modifies a database CREATE TABLE - creates a new table ALTER TABLE - modifies a table DROP TABLE - deletes a table CREATE INDEX - creates an index (search key) DROP INDEX - deletes an index

The "Persons" table: P_Id 1 2 3 LastName Hansen Svendson Pettersen FirstName Ola Tove Kari Address Timoteivn 10 Borgvn 23 Storgt 20 City Sandnes Sandnes Stavanger

If we use the following SELECT statement:


SELECT LastName,FirstName FROM Persons;

The result-set will look like this:


LastName Hansen Svendson Pettersen FirstName Ola Tove Kari

If we use the following SELECT statement:


SELECT * FROM Persons WHERE City='Sandnes; The result-set will look like this:
P_Id 1 2 LastName Hansen Svendson FirstName Ola Tove Address City Timoteivn 10 Sandnes Borgvn 23 Sandnes

INSERT INTO Persons VALUES (4,'Nilsen', 'Johan', 'Bakken 2', 'Stavanger');

The "Persons" table will now look like this:


P_Id 1 2 3 4 LastName Hansen Svendson Pettersen Nilsen FirstName Ola Tove Kari Johan Address Timoteivn 10 Borgvn 23 Storgt 20 Bakken 2 City Sandnes Sandnes Stavanger Stavanger

The "Persons" table:


P_Id 1 2 3 4 5 LastName Hansen Svendson Pettersen Nilsen Tjessem FirstName Ola Tove Kari Johan Jakob Address Timoteivn 10 Borgvn 23 Storgt 20 Bakken 2 City Sandnes Sandnes Stavanger Stavanger

Now we want to update the person "Tjessem, Jakob" in the "Persons" table.

We use the following SQL statement:

UPDATE Persons SET Address='Nissestien 67', City='Sandnes' WHERE LastName='Tjessem' AND FirstName='Jakob;
The "Persons" table will now look like this:

P_Id 1 2 3 4 5

LastName Hansen Svendson Pettersen Nilsen Tjessem

FirstName Ola Tove Kari Johan Jakob

Address Timoteivn 10 Borgvn 23 Storgt 20 Bakken 2 Nissestien 67

City Sandnes Sandnes Stavanger Stavanger Sandnes

We use the following SQL statement:

DELETE FROM Persons WHERE LastName='Tjessem' AND FirstName='Jakob;


The "Persons" table will now look like this:
P_Id 1 2 3 4 LastName Hansen Svendson Pettersen Nilsen FirstName Ola Tove Kari Johan Address Timoteivn 10 Borgvn 23 Storgt 20 Bakken 2 City Sandnes Sandnes Stavanger Stavanger

We use the following CREATE TABLE statement:

CREATE TABLE Persons (P_Id int,LastName varchar(255),FirstName varchar(255), Address varchar(255),City varchar(255));
The empty "Persons" table will now look like this: The empty table can be filled with data with the INSERT INTO statement.

P_Id

LastName FirstName

Addres City s

CREATE DATABASE my_db;

Transactional Mangement
Atomicity : Database modifications must follow an "all or nothing" rule. Consistency : Transaction should bring the database from one valid state to another. Isolation : No transactions that affect the same rows can run concurrently, since their sequence, and hence the outcome, would be unpredictable. Durability : once a transaction has been committed, it will remain so, even in the event of power loss, crashes, or errors.

Database system architecture


User Client User

Applications

Communication Applications network Communication network Application server

Physical Database
Two-tier Architecture

server

Physical Database
Three-tier Architecture

Database system architecture


Schema
Specifies the names of the entities and attributes and the relationship among them. It is a framework which remains fixed, where as the values fitted into this format changes from instance to instance. Schema can be Logical schema : - exploiting the data structures offered by a DBMS Physical schema : - The manner in which the conceptual database shall get represented in the computer as a stored database. The physical schema is hidden beneath the logical schema and can be changed easily without affecting the application progrm.

Database system architecture


Subschema Inherits the same property that a schema has. Refers to an application programmers view of the data item types and record types. A window to view a part of the database. Defines the portion of the database as seen by the application programs that actually produced the desired information from the data contained within the database. Instances When the schema framework is filled in the data item values or the contents of the database at any point of time, it is referred to as an instance of the database.

Você também pode gostar