0% found this document useful (0 votes)
6 views

DBMS Assignment 8

Uploaded by

mango0000007007
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

DBMS Assignment 8

Uploaded by

mango0000007007
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

DBMS Assignment

Name – Piyush Kumar


Section – CF
Roll no. – 14
Program – B.TECH CS(CSF)

Write the SQL queries to implement the concept of index and


sequence→

-- Q1. Create an index on column DoB of Student table


CREATE INDEX DoBindex ON Student(DoB);

-- Q2. Create a Bitmap Index named MAJORindex for the


major column in Apply
CREATE BITMAP INDEX MAJORindex ON Apply(major);

-- Q3. Remove the index on the DoB column


DROP INDEX DoBindex;

-- Q4. Create a Unique index ENRindex on enrollment in


College
CREATE UNIQUE INDEX ENRindex ON College(enrollment);
-- Q5. Create a composite Unique index SCMindex on Apply
using columns sID, cName, major
CREATE UNIQUE INDEX SCMindex ON Apply(sID, cName,
major);

-- Q6. Create a composite index on Apply using columns


cName and major named CMapplyINDX
CREATE INDEX CMapplyINDX ON Apply(cName, major);

-- Q7. Create sequence sID_seq with parameters increment


by 3, cycle, cache 4, starting from 988
CREATE SEQUENCE sID_seq
INCREMENT BY 3
START WITH 988
MAXVALUE 999
CYCLE
CACHE 4;

-- Q8. Display the next value of Sequence sID_seq


SELECT sID_seq.NEXTVAL FROM DUAL;

-- Q9. Insert a new student named Eric into the Student table
INSERT INTO Student (sID, sName, GPA, sizeHS, DoB)
VALUES (sID_seq.NEXTVAL, 'Eric', 9.9, 9999, TO_DATE('23-
Apr-98', 'DD-MON-YY'));

-- Q10. Insert another student named Troy into the Student


table
INSERT INTO Student (sID, sName, GPA, sizeHS, DoB)
VALUES (sID_seq.NEXTVAL, 'Troy', 9.8, 989, TO_DATE('25-
Nov-99', 'DD-MON-YY'));

-- Q11. Display details of the Student table


SELECT * FROM Student;

-- Q12. Create sequence GPA_seq with maximum value 5,


minimum value 3, starting from 5 and decrementing by -1,
cycle, no cache
CREATE SEQUENCE GPA_seq
START WITH 5
INCREMENT BY -1
MINVALUE 3
MAXVALUE 5
CYCLE
NO CACHE;
-- Q13. Update GPA of Eric to next value of sequence
GPA_seq
UPDATE Student SET GPA = GPA_seq.NEXTVAL WHERE
sName = 'Eric';

-- Q14. Insert a student named Jack into the Student table


INSERT INTO Student (sID, sName, GPA, sizeHS, DoB)
VALUES (sID_seq.NEXTVAL, 'Jack', GPA_seq.NEXTVAL, 1500,
TO_DATE('22-OCT-97', 'DD-MON-YY'));

-- Q15. Display details of the Student table


SELECT * FROM Student;

-- Q16. Display next value of sequence GPA_seq


SELECT GPA_seq.NEXTVAL FROM DUAL;

-- Q17. Drop sequence sID_seq


DROP SEQUENCE sID_seq;

-- Q18. Drop sequence GPA_seq


DROP SEQUENCE GPA_seq;
Pre-Experiment Questions:
Q1. What are indexes?
Ans. Indexes are data structures associated with Database
tables that improve the speed of data retrieval operations.
Q2. How they improve performance of retrieval in DBMS?
Ans. by reducing the number of disk I/O operations require to
fetch data, as they allow the database to quickly locate
specific rows based on indexed columns.
Q3. What is surrogate key?
Ans. A surrogate key is a unique identifier for each row in a
database table that is generated by the system rather than
being based on natural attributes of the data.
Post-Experiment Questions:
Q1. Can we create index on view?
Ans. Yes.
Q2. Difference between Bitmap index and B Tree Indexes?
Ans. Bitmap indexes are suitable for columns with low
cardinality (few distinct values), while B-tree indexes are
more suitable for high-cardinality columns. Bitmap indexes
store a bitmap for each distinct value in the indexed column,
while B-tree indexes use a balanced tree structure.
Q3. Why sequence are important?
1. Sequences are important in database management
systems for generating unique identifiers, such as
primary keys, in a concurrent and scalable manner.
2. Sequences help in implementing surrogate keys by
providing a reliable and efficient way to generate unique
identifiers for each row in a table.

You might also like