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

03 134192 002 8535071027 31032021 075354pm

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

Bahria University

Lahore Campus
Department of Computer Science
Database Management Systems (CSC-220)
Assignment No: 01
Total Marks: 20 Due Date: 31-03-2021

Name: Syed Faizan Alam Zaidi Enrollment: 03-134192-002 Class: BSCS - 4A

Objectives:

Q. No. Topics
1 Understand the SQL DDL and DML statements

Task:

You are required to write SQL queries for the given statement along with the report asked in deliverable A.

Deliverable:

1. A detailed report (approx. 700 words) to differentiate between the DDL and DML. (10 marks)
2. Detail SQL Queries (for given scenario) (10 marks)

 Selects all the customers from the country "Mexico", in the


"Customers" table?
 Select all records where the City column has the value "Berlin".
 selects all fields from "Customers" where country is "Germany" AND
city is "Berlin"
 selects all fields from "Customers" where city is "Berlin" OR
"München"
 selects all fields from "Customers" where country is NOT "Germany":
 Problem: List all customers from Spain or France from the table given.
 Problem: List all customers that are not from the USA

Note: The work should be described in your own words. Avoid Plagiarism.

Criteria:

Assessment criteria
Grades E/F D C B A
-Identify very few/none of the most -Identify a few of the - Identify some of the - Identify most of the - Identify all of the
significant techniques. most significant most significant most significant most significant
Weak report. Basic contents and techniques. techniques with techniques. techniques with
lacks flow, structure and Reasonable report. respective references. Good report. proper examples.
understanding, or, no/poor, Reasonable Satisfactory report. Overall good Excellent report.
irrelevant report. Poor structure and presentation and Good presentation and presentation and Well-structured and
presentation. structure. structure. structure. presented.
TASK: 1 A detailed report (approx. 700 words) to differentiate between the DDL and DML. (10 marks)
Solution:

DDL DML

DDL Stands for Data Definition Language. DML Stands for Data Manipulation Language.

With the help of the create command, we With the help of the insert command, we can insert
can create databases and tables. data into the table.
Example: Example:
create table employee(ID int, EMP_Name insert into employee (ID,EMP_Name)
nvarchar(20),age int default 20); values(1,'Faizan'),(2,'Ali'),(3,'Rehman');
DDL enables us to identify relations, as well
DML is a data manipulation language.
as the schema for each one.

We can delete our database, tables, and We can delete data from our tables by using the
columns using the drop command. delete command.

Example: Example:
alter table employee drop column gender; delete from Employee where id =1;

With the help of the alter command, we can With the help of the update command, we can make
change our tables and columns. changes to the data in the table.
Example:
Example:
alter table employee add gender
update employee set gender='Male' where id =1;
nvarchar(10);
DML is used to INSERT, DELETE, and UPDATE table
DDL is primarily used to define the table's
rows. One tuple/Record is also referred to as one
attributes (columns).
row.
Procedural and non-procedural DML are the two
There is no further classification for DDL.
types of DML.

In DDL, the where clause is not used. In DML, the where clause is used.

With the sp rename command, we can The merge command in the database can be used to
rename our tables and columns. merge two tables.

Task 2: Detail SQL Queries (for given scenario) (10 marks)


Solution:
create database Record;
use Record;
create table customer(ID int, C_Name varchar(40),Contact_Name varchar(35),
Addresss varchar(40),City varchar(20),Postal_Code varchar(20),Country varchar(15));

insert into customer values(01,'Alfreds Futterkiske','Maria Anders','Obere Str.57','Berlin',12209,'Germany');


insert into customer values(02,'Ana Trujillo Emparedados y helados','Ana Trujillo','Avda. de la Constitucion
2222','Mexico D.F.',05021,'Mexico');
insert into customer values(03,'Antonio Moreno Taqueria','Antonio Moreno','Mataderos 2312','Mexico
D.F.',05023,'Mexico');
insert into customer values(04,'Around the horn','Thomas Hardy','120 Hanover sq.','London','WA1
1DP','UK');
insert into customer values(05,'Berglunds snabbkob','Christina Berglund','Berguvsvagen 8','Lulea','S-958
22','Sweden');
select * from customer;

select * from customer where country='Mexico';

select * from customer where city='Berlin';

select * from customer where country='Germany' And city='Berlin';

select * from customer where city='Berlin' Or city='Munchen';


select * from customer where not country='Germany';

create table Person(ID int, FirstName varchar(25), LastName varchar(25), City Varchar(20), Country
varchar(20));
insert into Person values(07,'Frederique','Citeaux','Strasbourg','France');
insert into Person values(08,'Martin','Sommer','Madrid','Spain');
insert into Person values(09,'Laurence','Lebihan','Marseille','France');
insert into Person values(18,'Janine','Labrune','Nantes','France');
insert into Person values(22,'Diego','Roel','Madrid','Spain');
insert into Person values(23,'Martine','Rance','Lille','France');
select * from Person;

select * from Person where country='spain' or country='france';

select * from Person where Not country='USA';

You might also like