Sunteți pe pagina 1din 14

Database Languages

Data Data Transaction


Data Control Control
Definition Manipulation
Language Language
Language Language
(DCL) (TCL)
(DDL) (DML)
Data Definition Language
(DDL)
CREATE : is used to create the database or its objects (like table, index,
function, views, store procedure and triggers)

ALTER : is used to alter the structure of the database.

DROP : is used to delete objects from the database.

RENAME : is used to rename an object existing in the database.

COMMENT : is used to add comments to the data dictionary.

TRUNCATE : is used to remove all records from a table, including all spaces
allocated for the records are removed.
Data Manipulation Language
(DML)

SELECT – is used to retrieve data from the a database.

INSERT – is used to insert data into a table.

UPDATE – is used to update existing data within a table.

DELETE – is used to delete records from a database table.

CALL - call a PL/SQL or stored procedure


Data Control Language
(DCL)

GRANT- gives user’s access privileges to database.

REVOKE-withdraw user’s access privileges given by using the

GRANT command.
Transaction Control Language
(TCL)

COMMIT– commits a Transaction.

ROLLBACK– rollbacks a transaction in case of any error occurs.

SAVEPOINT – sets a save point within a transaction.

SET TRANSACTION - specify characteristics for the transaction.


Table Name :- Client_master

Column Data Type Size Attributes


Name
Client_no Varchar 6 Primary Key
First letter must
start with „C‟
Name Varchar 50 Not Null
Address1 Varchar 50

Address2 Varchar 50

City Varchar 25

State Varchar 25

Pincode Bigint

Bal_due Float
Table Name :- Product_master

Column Data Type Size Attributes


Name
Product_no Varchar 6 Primary Key
First letter must
start with „P‟
Description Varchar 50 Not Null
Profit_perce Float Not Null
nt
Unit_measur Varchar 10 Not Null
e
Qty_on_han Bigint Not Null
d
Reorder_val Bigint Not Null
ue
Sell_price Float Not Null

Cost_price Float Not Null


Table Name :- salesman_master

Column Data Type Size Attributes


Name
salesman_ Varchar 6 Primary Key
no First letter must
start with „S‟
Salesman_ Varchar 50 Not Null
name
Address1 Varchar 50 Not Null
Address2 Varchar 50
City Varchar 30 Not Null
Pincode Bigint
Sale_amt Float Not Null
Tgt_to_get Float Not Null
Remarks Ntext
Table Name :- sales_order

Column Data Size Attributes


Name Type
S_order_no Varchar 6 Primary Key
First letter must start with „O‟
S_order_date Datetime

Client_no Varchar 6 Foreign Key of client_master


Dely_address Varchar 50

Salesman_no Varchar 6 Foreign key of


salesman_master
Dely_type Char 1 Part(P)/Full (F)
Default „F‟
Billed_yn Char 1

Dely_date Datetime Cannot be less then


S_order_date
Order_status Varchar 20 In Process, Fulfilled,
Backorder, Canceled
Table Name :- sales_order_details

Column Data Size Attributes


Name Type
S_order_ Varchar 6 Foreign key of
no sales_order
Product_ Varchar 6 Foreign key of
no product_mast
er
Qty_orde Bigint
red
Qty_disp Bigint
Product_ Float
rate
Table Name :- challan_header

Column Data Size Attributes


Name Typ
e
Challan_no Varcha 6 Primary Key, First
r two letters must
start with „CH‟
S_order_no Varcha 6 Foreign key of
r sales_order
Challan_date Dateti
me

Billed_yn Char 1 Values (“Y”, “N”)


Default “N”
Table Name :- challan_details

Column Data Type Size Attributes


Name
Challan_no Varchar 6 Foreign Key of
Challan_header
Product_no Varchar 6 Foreign Key of
Product_master
Qty_disp Bigint Not null
Key

• Keys are used to identify any row of data in a table. In a real-world


application, a table could contain thousands of records. Moreover,
the records could be duplicated. Keys ensure that uniquely
identify a table record despite these challenges.

• Keys, establish a relationship between and identify the relation


between tables

• Help to enforce identity and integrity in the relationship.

• A DBMS key is an attribute or set of an attribute which helps to


identify a row(tuple) in a relation(table).

• Keys helps to uniquely identify a row in a table by a combination


of one or more columns in that table.
Super key : A superkey is a set of one or more attributes that, taken collectively, allow us to
identify uniquely an entity in the entity set. For example, the customer-id attribute of the entity
set customer is sufficient to distinguish one customer entity from another. Thus, customer-id is a
superkey. Similarly, the combination of customer-name and customer-id is a superkey for the
entity set customer. The customer-name attribute of customer is not a superkey, because
several people might have the same name.

Candidate key: Minimal superkeys are called candidate keys. If K is a superkey, then so is any
superset of K. We are often interested in superkeys for which no proper subset is a superkey. It is
possible that several distinct sets of attributes could serve as a candidate key. Suppose that a
combination of customer-name and customer-street is sufficient to distinguish among members
of the customer entity set. Then, both {customer-id} and {customer-name, customer-street} are
candidate keys. Although the attributes customerid and customer-name together can
distinguish customer entities, their combination does not form a candidate key, since the
attribute customer-id alone is a candidate key.

Primary key: which denotes the unique identity is called as primary key. primary key to denote a
candidate key that is chosen by the database designer as the principal means of identifying
entities within an entity set. A key (primary, candidate, and super) is a property of the entity set,
rather than of the individual entities. Any two individual entities in the set are prohibited from
having the same value on the key attributes at the same time. The designation of a key
represents a constraint in the real-world enterprise being modeled.

S-ar putea să vă placă și