Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

DBMS Part 2

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 16

SESSION 4: RETRIEVE DATA USING QUERY

PRIMARY KEY:- A primary key is a unique value that identifies a row in a


table. These keys are also indexed in the database, making it faster for the
database to search a record.

FOREIGN KEY:- The foreign key identifies a column or set of columns in one
(referencing) table that refers to a column or set of columns in another
(referenced) table.

Memorize it : one, parent, PK (Primary Key) ; many, child , FK


(Foreign Key)
There are two types of languages:-
1. DDL (Data Definition Language)
2. DML (Data Manipulation Language)

DATA DEFINITION / DESCRIPTION LANGUAGE:- It is a standard for commands that


define the different structures in a database. DDL statements create,modify and remove
database objects such as tables, indexes and users.
Common DDL Statements are:-
1. Create :- Used to create database objects.
2. Alter :- Used to modify database objects.
3. Drop :- Used to delete database objects.

DATA MANIPULATION LANGUAGE:-It is a standard for commands that enables users to


access and manipulate data in a database. Common DML Statements are:-
1. SELECT :- Used for retrieval of information from the database.
2. INSERT :- Used for insertion of new information into the database.
3. DELETE :- Used for deletion of information in the database.
4. UPDATE :- Used for modification of information in the database.
Types of DML:-
1.Procedural:- The user specifies what data is needed and how to get it.
2. Non Procedural :- The user only specifies what data is needed.
CREATE TABLE
VEHICLE(Vehicle_No
Integer(10),Make
varchar(10),Model
Numeric(10),Year Date and
Time,Price Decimal(8,2));

INSERT INTO
VEHICLE(‘1234’,’TATA’,’201’,’
2020’,’5000.25);
CREATING TABLE IN MYSQL Through Create table command we can define
any table.
Syntax :CREATE TABLE ([()],.......... );
CREATE TABLE info(Sno integer, Name varchar(10), City char(10), Age integer,
Company varchar(20), Salary decimal(8,2));

INSERT : This statement is used to insert new records into the table.
INSERT INTO Employee_Info VALUES ('02', 'Anay','Soumya', '9432156783', '
Marathalli House No 23', 'Delhi', 'India');
INSERT : This statement is used to insert new records into the table.
INSERT INTO
Employee(Emp_code,Emp_Name,Emp_Address,Emp_Designation,Emp_C
ontact,Emp_Salary) VALUES('E021', 'PRASHANT', 'KUWAIT CITY',
'DOCTOR', '123455', '1234.89');

UPDATE Employee SET Emp_Name = 'Aeej', Emp_Address=


'Ahmedabad' WHERE Emp_code = ‘E001’;

DELETE : This statement is used to delete the existing records in a table


DELETE FROM Employee WHERE Emp_Name='Aeej';
ALTER : This statement is used to add, delete, modify columns in an
existing table ALTER TABLE Employee_Info ADD BloodGroup
varchar(255);.

DROP : To Delete DROP DATABASE Employee (complete


information present in the database will be lost) DROP TABLE
TableName (complete information present in the table will be lost)

SELECT : This statement is used to select data from a database and


the data returned is stored in a result table, called the resultset.
SELECT EmployeeID, EmployeeName FROM Employee_Info; (*) is
used to select all from the table SELECT * FROM Employee_Info;
A SELECT statement retrieves zero or more rows from one or more
tables. SELECT is the most commonly used Data Manipulation
Language(DML) command. To retrieve all the columns in a table the
syntax is: SELECT * FROM <Table Name>;

For example, if you want to display all the data from table emp (short
form of employee), the command is

Select * from emp;

The SELECT statement has many optional clauses:

1. WHERE specifies which rows to retrieve.


2. ORDER BY specifies an order in which to return the rows.

for example : Select * from emp where name = “Ravi”;


__________ store data in Single table.
a. Flat File

b. Relational

c. Single File

d. One File

___________ are dedicated computers that hold the actual


databases and run only DBMS and related Software.
a. Main Server

b. Web Server

c. Database Server

d. Non Database Server


Which of the following will help to maintain unique record in the
table?
a. Foreign Key

b. Primary Key

c. Composite Key

d. Alternate Key

Which of the following field of table “Book” can act as primary key?
a. Book_number

b. Subject

c. price

d. Author_name
When primary key is made up of two or more columns then it is called
__ primary key.
a. Mixed

b. Reference

c. Composite

d. Compost

Duplicate values can be entered in primary key.(T/F)


a. True

b. False
CREATE TABLE BANK( ID_Number INTEGER(10) Primary Key,Name varchar(20),B_date
date,Address varchar(50));

INSERT INTO BANK( ID_Number,Name ,B_date,Address) VALUES(001,”Allen”,”17-03-


2004”,”Salmiya”);
INSERT INTO BANK( ID_Number,Name ,B_date,Address) VALUES(002,”Rachel”,”11-
012-2005”,”Rumaihiya”);
DELETE FROM BANK WHERE Name=”Rachel”;
UPDATE BANK SET Name =”Mufaddal” WHERE Id_Number=001;
Define the following terms
(i) INSERT Command (ii) SELECT Command(iii) DELETE Command (iv) DCL Command
(v) Template
Ans. (i) INSERT Command It is used to add a single record or multiple records into a
table.Syntax
INSERT INTO <table_name> (col1, col2.....) VALUES (val1, val2);
(ii) SELECT Command It is used to query or retrieve data from a table in the database.
Syntax SELECT column_list FROM table_name;
(iii) DELETE Command To discard unwanted data froma database, the delete command
is used.
SyntaxDELETE FROM <table_name> WHERE <condition>;
(iv) DCL Command DCL commands are used to assign
security levels in database which involves multiple
user setups. They are used to grant defined role and
access privileges to the users.
(v) Template It is a complete tracking application with
predefined tables, forms , reports, queries, macros
and relationship.
Identify the following devices.
(i) A device that is used to connect different types of networks. It performs the necessary translation,
so
that the connected networks can communicate properly.

(ii) A device that converts data from digital bit


stream into an analog signal and vice-versa.

What is URL? Can we use URL to access a web page? How?


Ans. URL means Uniform Resource Locator. It is a unique address of a web page on the Internet. It
specifies the Internet address of a file stored on a host computer connected to the Internet. Yes, as
a location on a web
server, which is called a website and each website has a unique address known as URL.

Write any two key features of an Instant Messaging(IM).


Ans. Key features of an Instant Messaging are :
(i) Video calling(ii) Language translation
List any five application based instant messaging
software. [CBSE Textbook]
Ans. Whatsapp, Viber, Skype, WeChat, Google Talk

You might also like