

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Two experiments related to database management. The first experiment focuses on implementing various types of constraints, including primary key, foreign key, check, unique, and not null constraints. The second experiment demonstrates the use of subqueries to retrieve data from multiple tables. Sql code examples and output for creating tables with different constraints, as well as for executing subqueries to display book details and the book with the maximum price. This information could be useful for students studying database management, sql programming, and related topics in computer science or information technology programs at the university level.
Typology: Cheat Sheet
1 / 3
This page cannot be seen from the preview
Don't miss anything!


Experiment No:
Aim: To implement Constraints
Primary Key Constraint
Program:
SQL>Create table book (bookid number(4) primary key, bookname varchar(20) not null ,authorname varchar(20), price number(8));
Output:
Table Created.
SQL>select *from book;
Output:
Foreign Key Constraint
Program:
SQL>Create table publisher(pubid number(4) primary key, pubname varchar(20) not null ,bookid number(4),foreign key(bookid)references book);
Output:
Table Created.
SQL>select *from publisher;
Output:
Check Constraint
Program:
SQL>Create table student (studentid number(4), studentname varchar(20), age number(3),sex char(10),batch varchar(25) check(batch in(‘science’,’commerce’)),total number(4));
Output:
Table Created.
SQL>select *from student;
Output:
Unique Constraint
Program:
SQL>Create table department (deptid number(4)Unique, deptname varchar(20),subject varchar(25));
Output:
Table Created.
Not Null Constraint
Program:
SQL>Create table college (collegeid number(4)not null, coursename varchar(20),location varchar(25));
Output:
Table Created.
Experiment No:
Aim: To implement Sub Queries
Program: Display the details of book published by PHI
SQL>select *from book where bookid in(select bookid from publisher where pname=’PHI’);
Output:
Program: select the book with max price