Important Announcement
PubHTML5 Scheduled Server Maintenance on (GMT) Sunday, June 26th, 2:00 am - 8:00 am.
PubHTML5 site will be inoperative during the times indicated!

Home Explore RDBMS Lab Manual

RDBMS Lab Manual

Published by Teamlease Edtech Ltd (Amita Chitroda), 2022-08-30 09:20:40

Description: Core Java Lab Manual

Search

Read the Text Version

JAVA RDBMS FULL STACK DEVELOPMENT

Objectives of this Lab Manual This lab manual includes - Exercises for hands on practice Guidelines to complete the exercise Learning Outcome

Contents This lab manual includes the following exercises- 1. Primary Key in Conceptual Modeling 2. CRUD Operations 3. Lambda Expressions

Primary Key in Conceptual Modeling

Problem What will you do? Statement Create a table with name STUDENT with attributes Name (varchar)(20), Age (int), Contact (int) and use Roll_no(int) as primary key

Solution What will be the steps Steps to get the output? • Step-1: Create a table with Table name Student • Step-2: Write the attributes given above • Step-3: Create Primary key • Step-4: Execute the SQL program

Code CREATE TABLE Student( Roll_no int, Name (varchar) (20), Age int, Contact int Primary Key (Roll_no) );

Output Output for the Adedxetercxitsheewreil:l- be :- CREATE TABLE Student( Roll_no int, Name (varchar) (20), Age int, Contact int Primary Key (Roll_no) );

Output Output for the Adedxetercxitsheewreil:l- be :- Full code--> CREATE TABLE Student( Roll_no int, Name (varchar) (20), Age int, Contact int Primary Key (Roll_no) );

Learning Outcome After Performing this Add teExxt ehrecries:e- You will be able to create a Primary Key.

CRUD Operation in RDBMS

Problem What will you do? Statement Create a new table, in that table Create a record, Read the record, Update the record, and delete a record from the given conditions.

Solution What will be the steps Steps to get the output? • Step1: - Create a table with the name mobile, and insert the values into the table for an e-commerce application, with the data items (Brand, model, and Price) • Note: Datatype for Mobile and model should be varchar(25)

Solution What will be the steps Steps to get the output? • Step 2: -Write a query to insert the values in the table Values: Brand Model Price Samsung A73 30000 iPhone iPhone 13 pro 90000 Iqoo Iqoo 9t 50000

Solution What will be the steps Steps to get the output? • Step 3: Write a query to Update the details in the table according to the given conditions • Conditions: Change Model A73 to A84from brand Samsung • Step 4: Write a query to delete the student record from the mobile table whose brand is iPhone

Code Code for step 1: CREATE TABLE Mobile(Brand varchar(25), model varchar(10), Price int); Code for step 2: insert into Mobile values('Samsung','A73',30000) insert into Mobile values('iPhone','13 Pro',90000) insert into Mobile values('Iqoo','Iqoo 9t',50000) Code for step 3: UPDATE Mobile SET Model = A84 WHERE Brand = “Samsung”; Code for step 4: DELETE FROM Mobile WHERE Brand = “iPhone”;

Output Output for the Adedxetercxitsheewreil:l- be :- Output for step 1:

Output Output for the Adedxetercxitsheewreil:l- be :- Output for step 2:

Output Output for the Adedxetercxitsheewreil:l- be :- Output for step 3:

Output Output for the Adedxetercxitsheewreil:l- be :- Output for step 4:

Learning Outcome After Performing this Add teExxt ehrecries:e- You will be able to create a table, read, update and delete the record on the table successfully.

Lambda Expressions

Problem What will you do? Statement Create a method that considers a lambda expression as a parameter.

Solution What will be the steps Steps to get the output? • Step-1: The method you are creating should have a parameter with a single-method interface similar to its type. • Step-2: Calling the interface's method will automatically run the lambda expression • Step-3: Use a lambda expression in a method • Step-4: Execute to achieve the desired output.

Code Code : interface StringFunction { String run(String str); } public class Main { public static void main(String[] args) { StringFunction exclaim = (s) -> s + \"!\"; StringFunction ask = (s) -> s + \"?\"; printFormatted(\"Hello\", exclaim);

Code Code : printFormatted(\"Hello\", ask); } public static void printFormatted(String str, StringFunction format) { String result = format.run(str); System.out.println(result); } }

Learning Outcome After Performing this Add teExxt ehrecries:e- You will be able to implement the lambda expression successfully.

Happy Learning!


Like this book? You can publish your book online for free in a few minutes!
Create your own flipbook