Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
15 views3 pages

CO226 Lab02

The document outlines a lab assignment for a Database Systems course, focusing on writing MySQL queries. It includes tasks such as creating tables with specified fields and constraints, inserting records into those tables, and performing various SQL queries to manipulate and retrieve data. Students are required to take screenshots of their work and compile them into a PDF for submission.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views3 pages

CO226 Lab02

The document outlines a lab assignment for a Database Systems course, focusing on writing MySQL queries. It includes tasks such as creating tables with specified fields and constraints, inserting records into those tables, and performing various SQL queries to manipulate and retrieve data. Students are required to take screenshots of their work and compile them into a PDF for submission.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

CO226-Apr2025 : Database Systems

Lab 02 : Writing MySQL Queries I

Perform the following tasks using MySQL.

Take Screenshots and save them and after the lab create a pdf using the
screenshots and rename as E21XXX_CO226_Lab02.pdf and upload to LMS.

1.​ Recreate the following tables with relationships using MySQL syntaxes.​

Publisher Table

Field Name Type Field Size Constraints

PubID Text (varchar) 6 Primary Key

PublisherName Text (varchar) 30

RegisteredDate Date

Country Text (varchar) 15

​ Book Table

Field Name Type Field Size Constraints

BookID Text (varchar) 5 Primary Key

Title Text (varchar) 50

Author Text (varchar) 30

Category Number (int)

Price Currency (float)

PubID Text (varchar) 6 Foreign Key


2.​ Insert following records to Publisher table and Book table.

​ Book

Book ID Title Author Category Price PubID ​


B1 Excel R. David 2 18.00 Pub02

B2 Computers M. Thomas 4 25.00 Pub02

B3 Access P. Paul 2 30.00 Pub03

B4 Arts W. Shiva 1 10.00 Pub04



B5 Science A. Rahul 3 9.00 Pub01

​ Publisher

PubID PublisherName RegisteredDate Country

Pub01 A.Press 2001-05-12 Sri Lanka

Pub02 A.Books 2010-03-20 India

Pub03 K.Brill 2014-01-31 Poland

Pub04 A.Press 2015-02-13 Sri Lanka

3.​ Write SQL queries/statements considering the following table. Table Name: Book
a.​ Display all the details in the Book table
b.​ Display all the titles of the books.
c.​ Display all the titles of the books with prices
d.​ Display the Book ID, the Title and the Author.
e.​ Display the details of the book with the Book ID B2.
f.​ Display the titles of the books with the prices less than 20.00
g.​ Display the details of the books in category 2.​

4.​ Write queries


a.​ Display all the Titles in the Book table in ascending order.
b.​ Display all the details in the Book table in descending order by Price.
c.​ Display all the details in the Book table in ascending order by Price and
Title.
5.​ Write SQL queries/statements considering the ‘Book’ table
a.​ Change the category as 3 of the book with the BookID ‘B3’.
b.​ Change the price of the book with the BookID ‘B3’ by adding 10.00 to the
current price.
c.​ Delete the details of the book with the BookID ‘B3’.
d.​ Delete all the books in category 2.
e.​ Remove all the data in the Book table.

You might also like