BCS403-Lab Manual
BCS403-Lab Manual
RV Educational Institutions®
RV Institute of Technology and
Management
(Affiliated to VTU, Belagavi)
Lab Manual
Sl Particulars
No
1 SYLLABUS
2 INTRODUCTION TO DATABASE
3 BASIC QUERIES IN SQL
4 PRACTISE EXERCISES
5 EXPERITMENT 1 – Create user and Grant DB permissions
6 EXPERITMENT 2 – Employee Table and Basic DML operations
7 EXPERITMENT 3 - Employee Table and Aggregate operations
8 EXPERITMENT 4 – Customer Table and Create row level Trigger
9 EXPERITMENT 5 - Create cursor for Employee table
10 EXPERITMENT 6 - PL/SQL code using parameterized Cursor
11 EXPERITMENT 7 - Install an MangoDB and Create CRUD operation
12 VIVA QUESTIONS
DATABASE MANAGEMENT
SYSTEMS(BCS403) 1
RV Institute of Technology and
Management®
DATABASE MANAGEMENT
SYSTEMS(BCS403) 2
RV Institute of Technology and
Management®
DATABASE MANAGEMENT
SYSTEMS(BCS403) 3
RV Institute of Technology and
Management®
Laboratory Outcome
DATABASE MANAGEMENT
SYSTEMS(BCS403) 4
RV Institute of Technology and
Management®
Define the basics of Databases, Relational model, Relational Algebra and explore the needs and
concepts of SQL queries, Normalization rules, transaction processing and NoSQL concepts.
Demonstrate and describe database objects, enforce integrity constraints, implement
the transaction processing on a database and NoSQL databases.
Apply the knowledge of DBMS architecture, Relational algebra, Database design concepts,
transaction processing techniques and NoSQL concepts to design and build simple database
applications.
Develop applications using relational data model concepts or NoSQL.
The weightage of Continuous Internal Evaluation (CIE) is 50% and for Semester End
Exam (SEE) is 50%. The minimum passing mark for the CIE is 40% of the maximum
marks (20 marks). A student shall be deemed to have satisfied the academic requirements
and earned the credits allotted to each subject/ course if the student secures not less than
35% (18 Marks out of 50) in the semester-end examination (SEE), and a minimum of
40% (40 marks out of 100) in the sum total of the CIE (Continuous Internal Evaluation)
and SEE (Semester End Examination) taken together
CIE for the theory component of the IPCC (maximum marks 50)
● IPCC means practical portion integrated with the theory of the course.
● CIE marks for the theory component are 25 marks and that for the practical component is 25 marks.
● 25 marks for the theory component are split into 15 marks for two Internal Assessment Tests
(Two Tests, each of 15
DATABASE MANAGEMENT
SYSTEMS(BCS403) 5
RV Institute of Technology and
Management®
Marks with 01-hour duration, are to be conducted) and 10 marks for other assessment methods
mentioned in
22OB4.2. The first test at the end of 40-50% coverage of the syllabus and the second test after
covering 85-90% of
the syllabus.
● Scaled-down marks of the sum of two tests and other assessment methods will be CIE marks for
the theory
● The student has to secure 40% of 25 marks to qualify in the CIE of the theory component of IPCC.
● 15 marks for the conduction of the experiment and preparation of laboratory record, and 10 marks
for the test to be
● The CIE marks awarded in the case of the Practical component shall be based on the
continuous evaluation of the
DATABASE MANAGEMENT
SYSTEMS(BCS403) 6
RV Institute of Technology and
Management®
laboratory report. Each experiment report can be evaluated for 10 marks. Marks of all experiments’
write-ups are
● The laboratory test (duration 02/03 hours) after completion of all the experiments shall be
conducted for 50 marks
● Scaled-down marks of write-up evaluations and tests added will be CIE marks for the laboratory
component of IPCC
for 25 marks.
● The student has to secure 40% of 25 marks to qualify in the CIE of the practical
component of the IPCC.
Theory SEE will be conducted by University as per the scheduled timetable, with common question papers
for the course
(duration 03 hours)
1. The question paper will have ten questions. Each question is set for 20 marks.
2. There will be 2 questions from each module. Each of the two questions under a module (with a
maximum of 3 subquestions),
DATABASE MANAGEMENT
SYSTEMS(BCS403) 7
RV Institute of Technology and
Management®
3. The students have to answer 5 full questions, selecting one full question from each module.
The theory portion of the IPCC shall be for both CIE and SEE, whereas the practical portion will have
a CIE
component only. Questions mentioned in the SEE paper may include questions from the practical
component.
DATABASE MANAGEMENT
SYSTEMS(BCS403) 8
RV Institute of Technology and
Management®
INTRODUCTION TO DATABASE
What is Database?
A database is a separate application that stores a collection of data. Each database has one or
more distinct APIs for creating, accessing, managing, searching, and replicating the data it
holds. now a days we use relational database management systems (RDBMS) to store and
manager huge volume of data.
RDBMS Terminology:
Table: A table is a matrix with data. A table in a database looks like a simple spreadsheet.
Column: One column (data element) contains data of one and the same kind, for example the column
postcode. or phone numbers
Row: A row (= tuple, entry or record) is a group of related data, for example the data of one
subscription.
DATABASE MANAGEMENT
SYSTEMS(BCS403) 9
RV Institute of Technology and
Management®
Primary Key: A primary key is unique. A key value can not occur twice in one table. With a key
you can find at most one row.
Foreign Key: A foreign key is the linking pin between two tables.
Compound Key: A compound key (composite key) is a key that consists of multiple columns,
because one column is not sufficiently unique.
Referential Integrity: Referential Integrity makes sure that a foreign key value always points
to an
existing row.
DDL or Data Definition Language actually consists of the SQL commands that can be used to
to create and modify the structure of database objects in a database. These database objects
include views, schemas, tables, indexes, etc.
Some examples:
CREATE - to create objects in the database
ALTER - alters the structure of the database
DROP - delete objects from the database
DML is Data Manipulation Language statements: which are used to interact with a
database by deleting, inserting, retrieving, or updating data in the database.
Some examples:
SELECT - retrieve data from the a database INSERT - insert data into a table
UPDATE - updates existing data within a table
DELETE - deletes all records from a table, the space for the records remain
DCL is Data Control Language statements: which includes commands such as GRANT
and REVOKE which mainly deals with the rights, permissions and other controls of the
database system.
DATABASE MANAGEMENT
SYSTEMS(BCS403) 10
RV Institute of Technology and
Management®
CREATE TABLE
Specifies a new base relation by giving it a name, and specifying each of its attributes and their data
types
Syntax of CREATE Command:
DATABASE MANAGEMENT
SYSTEMS(BCS403) 11
RV Institute of Technology and
Management®
CREATE TABLE
ORDERS (
ORDER_ID INT (6) PRIMARY KEY,
ORDER_DATE DATE
);
[alter specification] is dependent on the type of alteration we wish to perform. alter specification is
already mentioned above
DATABASE MANAGEMENT
SYSTEMS(BCS403) 12
RV Institute of Technology and
Management®
You can rename a column in MySQL using the ALTER TABLE and CHANGE commands together
to change an existing column.
For example,say the column is currently named JOB, but you decide that DESIGNATION is a more
appropriate title. The column is located on the table entitled ORDERS.
DELETING COLUMN
RENAMING A TABLE
DATABASE MANAGEMENT
SYSTEMS(BCS403) 13
RV Institute of Technology and
Management®
The DROP TABLE statement is used to drop an existing table in a database DROP
TABLE TABLENAME;
Example: DROP TABLE ORDER
if we wish to simply get rid of the data but not the table itself? For this, we can use the
Example:TRUNCATE customer
CONSTRAINTS:
Primary Key:-
A primary key is used to uniquely identify each row in a table. It can either be part of
the actual record itself, or it can be an artificial field (one that has nothing to do with the
DATABASE MANAGEMENT
SYSTEMS(BCS403) 14
RV Institute of Technology and
Management®
actual record).
A primary key can consist of one or more fields on a table. When multiple fields are
used as a primary key, they are called a composite key.
Primary keys can be specified either when the table is created (using CREATE
TABLE) or by changing the existing table structure (using ALTER TABLE).
Below are examples for specifying a primary key when creating a table:
Example :
CREATE TABLE ORDERS (ORDER_ID INT (6) PRIMARY KEY, ORDER_DATE DATE);
Below are examples for specifying a primary key by altering a table: CREATE TABLE ORDERS
(ORDER_ID INT (6), ORDER_DATE DATE);
Note: - Before using the ALTER TABLE command to add a primary key, you'll need to make
sure that the field is defined as 'NOT NULL' -- in other words, NULL cannot be an accepted
value for that field.and column values must be unique
FOREIGN KEY
A foreign key is a field (or fields) that points to the primary key of another table.
The purpose of the foreign key is to ensure referential integrity of the data. In other
words, only values that are supposed to appear in the database are permitted
For example, say we have two tables, a CUSTOMER table that includes all customer
DATABASE MANAGEMENT
SYSTEMS(BCS403) 15
RV Institute of Technology and
Management®
data, and an ORDERS table that includes all customer orders. The constraint here is that
all orders must be associated with a customer that is already in the CUSTOMER table.
In this case, we will place a foreign key on the ORDERS table and have it relate to the
primary key of the CUSTOMER table. This way, we can ensure that all orders in the
ORDERS table are related to a customer in the CUSTOMER table. .In other words, the
ORDERS table cannot contain information on a customer that is not in the CUSTOMER
table.
CREATE TABLE
CUSTOMER (
SID INT PRIMARY KEY,
Last_Name varchar(50),
First_Name varchar(50)
);
In the below example, the Customer_SID column in the ORDERS table is a foreign
key pointing to the SID column which is primary key in the CUSTOMER table.
DATABASE MANAGEMENT
SYSTEMS(BCS403) 16
RV Institute of Technology and
Management®
Below we show examples of how to specify the foreign key when creating the
ORDERS table: CREATE TABLE ORDERS
(
Order_ID int,
Order_Date
date,
Customer_SID
int, Amount
double,
Primary Key (Order_ID),
Foreign Key (Customer_SID) references CUSTOMER(SID)
);
NOT NULL Constraint:-By default, a column can hold NULL. If you want to allow
or store NULL value in a column, you will want to place a constraint on this column
specifying that NULL is now not an allowable value.
DATABASE MANAGEMENT
SYSTEMS(BCS403) 17
RV Institute of Technology and
Management®
UNIQUE Constraint:-The UNIQUE constraint ensures that all values in a column are distinct.
CHECK Constraint:-The CHECK constraint ensures that all values in a column satisfy certain
conditions. Once defined, the database will only insert a new row or update an existing row if the
new
value satisfies the CHECK constraint. The CHECK constraint is used to ensure data quality.
DATABASE MANAGEMENT
SYSTEMS(BCS403) 18
RV Institute of Technology and
Management®
• Hence, an SQL relation (table) is a multi-set (sometimes called a bag) of tuples;not a set of
tuples
• SQL relations can be constrained to be sets by using the CREATE UNIQUE INDEX
command, or by using the DISTINCT option
DATA TYPES:
1. CHAR (Size): This data type is used to store character strings values of fixed length. The size in
brackets determines the number of characters the cell can hold. The maximum number of
character is 255 characters.
2. VARCHAR (Size) / VARCHAR2 (Size): This data type is used to store variable length
alphanumeric data. The maximum character can hold is 2000 character.
3. NUMBER (P, S): The NUMBER data type is used to store number (fixed or floating point).
Number of virtually any magnitude may be stored up to 38 digits of precision. Number as large
as 9.99 * 10 124. The precision (p) determines the number of places to the right of the decimal.
If scale is omitted then the default is zero. If precision is omitted, values are stored with their
original precision up to the maximum of 38 digits.
4. DATE: This data type is used to represent date and time. The standard format is DD- MM-YY as
in 17-SEP-2009. To enter dates other than the standard format, use the appropriate functions.
Date time stores date in the 24-Hours format. By default the time
in a date field is 12:00:00 am, if no time portion is specified. The default date for a date field is the
first day the current month.
5. LONG: This data type is used to store variable length character strings containing up to 2GB.
Long data can be used to store arrays of binary data in ASCII format. LONG values cannot be
indexed, and the normal character functions such as SUBSTR cannot be applied.
DATABASE MANAGEMENT
SYSTEMS(BCS403) 19
RV Institute of Technology and
Management®
6. RAW: The RAW data type is used to store binary data, such as digitized picture or image. Data
loaded into columns of these data types are stored without any further conversion. RAW data
type can have a maximum length of 255 bytes. LONG RAW data type can contain up to 2GB.
Clauses, which are in some cases optional, constituent components of statements and queries.
Expressions, which can produce either scalar values or tables consisting of columns and rows of
data.
Predicates which specify conditions that can be evaluated to SQL three-valued logic (3VL)
Boolean truth values and which are used to limit the effects of statements and queries, or to
change program flow.
Queries which retrieve data based on specific criteria.
Statements which may have a persistent effect on schemas and data, or which may control
transactions, program flow, connections, sessions, or diagnostics.
SQL statements also include the semicolon (";") statement terminator. Though not required on
every platform, it is defined as a standard part of the SQL grammar.
Insignificant white space is generally ignored in SQL statements and queries, making it easier to
format SQL code for readability.
DATABASE MANAGEMENT
SYSTEMS(BCS403) 20
RV Institute of Technology and
Management®
1. DATA DEFINITION LANGUAGE (DDL): The Data Definition Language (DDL) is used to
create and destroy databases and database objects. These commands will primarily be used by
database administrators during the setup and removal phases of a database project.
Let's take a look at the structure and usage of four basic DDL commands:
1. CREATE 2. ALTER 3. DROP 4. RENAME
1. CREATE:
(a)CREATE TABLE: This is used to create a new relation (table)
Example:
SQL> CREATE TABLE Student (sno NUMBER (3), sname CHAR (10), class CHAR (5));
2. ALTER:
(a) ALTER TABLE ...ADD...: This is used to add some extra fields into existing relation.
Syntax: ALTER TABLE relation_name ADD (new field_1 data_type(size), new field_2
data_type(size),..);
Example: SQL>ALTER TABLE std ADD (Address CHAR(10));
(b) ALTER TABLE...MODIFY...: This is used to change the width as well as data type of fields of
existing relations.
DATABASE MANAGEMENT
SYSTEMS(BCS403) 21
RV Institute of Technology and
Management®
d) ALTER TABLE..RENAME...: This is used to change the name of fields in existing relations.
Syntax: ALTER TABLE relation_name RENAME COLUMN (OLD field_name) to (NEW
field_name);
DATABASE MANAGEMENT
SYSTEMS(BCS403) 22
RV Institute of Technology and
Management®
Objective:
NUMBER FUNCTION:
Abs(n) :Select abs(-15) from dual; Exp(n): Select exp(4) from dual; Power(m,n): Select power(4,2)
from dual; Mod(m,n): Select mod(10,3) from dual;
Round(m,n): Select round(100.256,2) from dual; Trunc(m,n): ;Select trunc(100.256,2) from dual;
Sqrt(m,n);Select sqrt(16) from dual;
Develop aggregate plan strategies to assist with summarization of several data entries.
Aggregative operators: In addition to simply retrieving data, we often want to perform some
computation or summarization. SQL allows the use of arithmetic expressions. We now consider
a powerful class of constructs for computing aggregate values such as MIN and SUM.
1. Count: COUNT following by a column name returns the count of tuple in that column. If
DISTINCT keyword is used then it will return only the count of unique tuple in the column.
Otherwise, it will return count of all the tuples (including duplicates) count (*) indicates all the
tuples of the column.
Syntax: COUNT (Column name)
DATABASE MANAGEMENT
SYSTEMS(BCS403) 23
RV Institute of Technology and
Management®
3. AVG: AVG followed by a column name returns the average value of that column
values. Syntax: AVG (n1, n2...)
Example: Select AVG (10, 15, 30) FROM DUAL;
4. MAX: MAX followed by a column name returns the maximum value of that
column. Syntax: MAX (Column name)
Example: SELECT MAX (Sal) FROM emp;
SQL> select deptno, max(sal) from emp group by deptno;
10 5000
20 3000
30 2850
SQL> select deptno, max (sal) from emp group by deptno having max(sal)<3000; DEPTNO
MAX(SAL)
30 2850
5. MIN: MIN followed by column name returns the minimum value of that column.
Syntax: MIN (Column name)
Example: SELECT MIN (Sal) FROM emp;
DATABASE MANAGEMENT
SYSTEMS(BCS403) 24
RV Institute of Technology and
Management®
CHARACTER FUNCTION:
initcap(char) : select initcap(“hello”) from dual; lower (char): select lower (‘HELLO’) from dual;
upper (char) :select upper (‘hello’) from dual;
ltrim (char,[set]): select ltrim (‘cseit’, ‘cse’) from dual; rtrim (char,[set]): select rtrim (‘cseit’, ‘it’)
from dual;
replace (char,search ): select replace(‘jack and jue’,‘j’,‘bl’) from dual;
CONVERSION FUNCTIONS:
To_char: TO_CHAR (number) converts n to a value of VARCHAR2 data type, using the optional
number format fmt. The value n can be of type NUMBER, BINARY_FLOAT, or
BINARY_DOUBLE.
STRING FUNCTIONS:
DATABASE MANAGEMENT
SYSTEMS(BCS403) 25
RV Institute of Technology and
Management®
Concat: CONCAT returns char1 concatenated with char2. Both char1 and char2 can be any of the
datatypes.
SQL>SELECT CONCAT(‘ORACLE’,’CORPORATION’)FROM DUAL;
ORACLECORPORATION
Lpad: LPAD returns expr1, left-padded to length n characters with the sequence of
characters in expr2.
SQL>SELECT LPAD(‘ORACLE’,15,’*’)FROM DUAL;
*********ORACLE
Rpad: RPAD returns expr1, right-padded to length n characters with expr2, replicated asmany
times as necessary.
SQL>SELECT RPAD (‘ORACLE’,15,’*’)FROM DUAL;
ORACLE*********
Upper: Returns a character expression with lowercase character data converted to uppercase
SQL>SELECT UPPER(‘dbms’)FROM DUAL;
DBMS
Length: Returns the number of characters, rather than the number of bytes, of the givenstring
expression, excluding trailing blanks.
SQL>SELECT LENGTH(‘DATABASE’)FROM DUAL;8
DATABASE MANAGEMENT
SYSTEMS(BCS403) 26
RV Institute of Technology and
Management®
Instr: The INSTR functions search string for substring. The function returns an integer
indicating the position of the character in string that is the first character of this occurrence.SQL>SELECT
INSTR('CORPORATE FLOOR','OR',3,2)FROM DUAL;
14
DATE FUNCTIONS:
Sysdate:
SQL>SELECT SYSDATE FROMDUAL;
next_day:
SQL>SELECT NEXT_DAY(SYSDATE,’WED’)FROM DUAL
add_months:
SQL>SELECT ADD_MONTHS(SYSDATE,2)FROM DUAL;
last_day:
SQL>SELECT LAST_DAY(SYSDATE)FROM DUAL;
months_between:
SQL>SELECT MONTHS_BETWEEN(SYSDATE,HIREDATE)FROM EMP;
Least:
SQL>SELECT LEAST('10-JAN-07','12-OCT-07')FROM DUAL;
Greatest:
SQL>SELECT GREATEST('10-JAN-07','12-OCT-07')FROM DUAL;
DATABASE MANAGEMENT
SYSTEMS(BCS403) 27
RV Institute of Technology and
Management®
Lab Programs
Create a table called Employee & execute the following.
1 Employee(EMPNO, ENAME, JOB, MANAGER_NO, SAL, COMMISSION)
1. Create a user and grant all permissions to theuser.
2. Insert the any three records in the employee table contains attributes EMPNO,ENAME JOB,
MANAGER_NO, SAL, COMMISSION and use rollback. Check the result.
3. Add primary key constraint and not null constraint to the employee table.
4. Insert null values to the employee table and verify the result.
28
DATABASE MANAGEMENT SYSTEMS(BCS403)
RV Institute of Technology and
Management®
4. SQL>Adding primary key constraint and not null constraint to the Employee
table ALTER TABLE Employee
ADD CONSTRAINT PK_Employee_EMPNO PRIMARY KEY (EMPNO),
ADD CONSTRAINT CHK_SALARY CHECK (SAL > 0),
MODIFY ENAME VARCHAR(50) NOT
NULL, MODIFY JOB VARCHAR(50) NOT
NULL, MODIFY SAL DECIMAL(10,2) NOT
NULL;
2 Create a table called Employee that contain attributes EMPNO, ENAME, JOB, MGR,SAL &
execute the following.
1. Add a column commission with domain to the Employeetable.
2. Insert any five records into the table.
3. Update the column details of job
4. Rename the column of Employ table using alter command.
5. Delete the employee whose Empno is 105
);
3. SQL>UPDATE
Employee SET JOB =
'Executive' WHERE
EMPNO = 105;
30
DATABASE MANAGEMENT SYSTEMS(BCS403)
RV Institute of Technology and
Management®
3 Queries using aggregate functions (COUNT, AVG, MIN, MAX, SUM), Group by, Orderby.
Employee(E_id, E_name, Age, Salary)
1. Create Employee table containing all Records E_id, E_name, Age, Salary.
2. Count number of employee names from employeetable
3. Find the Maximum age from employee table.
4. Find the Minimum age from employeetable.
5. Find salaries of employee in Ascending Order.
6. Find grouped salaries of employees.
31
DATABASE MANAGEMENT SYSTEMS(BCS403)
RV Institute of Technology and
Management®
Salary DECIMAL(10, 2) );
32
DATABASE MANAGEMENT SYSTEMS(BCS403)
RV Institute of Technology and
Management®
33
DATABASE MANAGEMENT SYSTEMS(BCS403)
RV Institute of Technology and
Management®
6. SQL> SELECT Salary, COUNT(*) AS Employee Count FROM Employee GROUP BY Salary;
4 Create a row level trigger for the customers table that would fire for INSERT or UPDATE or
DELETE operations performed on the CUSTOMERS table. This trigger will display the salary
difference between the old & new Salary. CUSTOMERS(ID, NAME, AGE, ADDRESS,
SALARY)
First Create table called customer and insert records into table
34
DATABASE MANAGEMENT SYSTEMS(BCS403)
RV Institute of Technology and
Management®
SALARY DECIMAL(10, 2)
);
SQL>>>Table created successfully.
35
DATABASE MANAGEMENT SYSTEMS(BCS403)
RV Institute of Technology and
Management®
IF INSERTING THEN
SET old_salary = NULL;
SET new_salary =
NEW.salary; ELSEIF
UPDATING THEN
SET old_salary = OLD.salary;
SET new_salary =
NEW.salary; ELSEIF
DELETING THEN
SET old_salary =
OLD.salary; SET new_salary
= NULL; END IF;
First Create table called Employee and insert records into table
1. SQL>CREATE TABLE Employee
( E_id INT PRIMARY KEY,
E_name VARCHAR(255),
Age INT,
Salary DECIMAL(10, 2) );
SQL>
-- Declare variables to store cursor values
DECLARE emp_id INT;
DECLARE emp_name VARCHAR(255);
DECLARE emp_age INT;
DECLARE emp_salary DECIMAL(10, 2);
37
DATABASE MANAGEMENT SYSTEMS(BCS403)
RV Institute of Technology and
Management®
END IF;
6 Write a PL/SQL block of code using parameterized Cursor, that will merge the data available in
the newly created table N_RollCall with the data available in the table O_RollCall. If the data in
the first table already exist in the second table then that data should be skipped.
SQL> DECLARE
-- Variables to store data from
N_RollCall n_id N_RollCall.ID%TYPE;
n_name N_RollCall.Name%TYPE;
n_date N_RollCall.Date%TYPE;
n_status N_RollCall.Status%TYPE;
38
DATABASE MANAGEMENT SYSTEMS(BCS403)
RV Institute of Technology and
Management®
skipped_rows NUMBER := 0;
BEGIN
-- Open the cursor
OPEN n_cursor;
31
0
DATABASE MANAGEMENT SYSTEMS(BCS403)
RV Institute of Technology and
Management®
END;
7 Install an Open Source NoSQL Data base MangoDB & perform basic CRUD(Create, Read,
Update & Delete) operations. Execute MangoDB basic Queries using CRUD operations
Install MongoDB:
Step:1 Download MongoDB Community Server from the official website: MongoDB Download
Center Follow the installation instructions provided for your operating system.
Start MongoDB Server:
Step: 2 After installation, start the MongoDB server. The method to start the server varies based on
your operating system. For example, on Windows, you can start it from the command line using
mongod, while on macOS or Linux, you can use sudo service mongod start.
Connect to MongoDB:
Step: 3 Open a terminal or command prompt and connect to the MongoDB server using the
mongo shell command. Perform CRUD Operations:
Step: 4 Once connected to the MongoDB server, you can perform basic CRUD operations using
the mongo shell or a MongoDB client like MongoDB Compass.
>>db.books.insertOne({ title: "MongoDB Basics", author: "John Doe", pages: 200 });
40
DATABASE MANAGEMENT SYSTEMS(BCS403)
RV Institute of Technology and
Management®
41
DATABASE MANAGEMENT SYSTEMS(BCS403)
RV Institute of Technology and
Management®
1. What is database?
2. What is DBMS?
1. Redundancy is controlled.
2. Unauthorised access is restricted.
3. Providing multiple user interfaces.
4. Enforcing integrity constraints.
5. Providing backup and recovery.
42
DATABASE MANAGEMENT SYSTEMS(BCS403)
RV Institute of Technology and
Management®
1. Physical level: The lowest level of abstraction describes how data are stored.
43
DATABASE MANAGEMENT SYSTEMS(BCS403)
RV Institute of Technology and
Management®
higher level.
Two types of Data Independence:
A view may be thought of as a virtual table, that is, a table that does not really
exist in its own right but is instead derived from one or more underlying base
table. In other words, there is no stored file that direct represents the view instead
a definition of view is stored in data dictionary.
Growth and restructuring of base tables is not reflected in views. Thus the
view can insulate users from the effects of restructuring and growth in the
database. Hence accounts for logicaldata independence.
This data model is based on real world that consists of basic objects called
entities and of relationship among these objects. Entities are described in
a database by a set of attributes.
44
DATABASE MANAGEMENT SYSTEMS(BCS403)
RV Institute of Technology and
Management®
The collections of entities of a particular entity type are grouped together into
an entity set.
An entity set may not have sufficient attributes to form a primary key, and
its primary key compromises of its partial key and primary key of its parent
entity, then it is said to be WeakEntity set.
45
DATABASE MANAGEMENT SYSTEMS(BCS403)
RV Institute of Technology and
Management®
46
DATABASE MANAGEMENT SYSTEMS(BCS403)
RV Institute of Technology and
Management®
47
DATABASE MANAGEMENT SYSTEMS(BCS403)
RV Institute of Technology and
Management®
It guarantees that the spurious tuple generation does not occur with respect to
relation schemas after decomposition.
The domain of attribute must include only atomic (simple, indivisible) values.
48
DATABASE MANAGEMENT SYSTEMS(BCS403)
RV Institute of Technology and
Management®
1. X is a Super-key of R.
2. A is a prime attribute of R.
1. Atomicity: Either all actions are carried out or none are. Users should
not have to worry about the effect of incomplete transactions. DBMS
ensures this by undoing the actions of incomplete transactions.
49
DATABASE MANAGEMENT SYSTEMS(BCS403)
RV Institute of Technology and
Management®
A query with respect to DBMS relates to user commands that are used to
interact with a data base. Thequery language can be classified into data
definition language and data manipulation language.
Subqueries, or nested queries, are used to bring back a set of rows to be used
by the parent query. Depending on how the subquery is written, it can be
executed once for the parent query or it can be
executed once for each row returned by the parent query. If the subquery is
executed for eachrow of the parent, this is called a correlated subquery.
50
DATABASE MANAGEMENT SYSTEMS(BCS403)
RV Institute of Technology and
Management®
43. Are the resulting relations of PRODUCT and JOIN operation the same?
No.
PRODUCT: Concatenation of every row in one relation with every row in another.
JOIN: Concatenation of rows from one relation and related rows from another.
44. Which part of the RDBMS takes care of the data dictionary? How?
47. Define SQL and state the differences between SQL and other
conventionalprogramming Languages.
51
DATABASE MANAGEMENT SYSTEMS(BCS403)
RV Institute of Technology and
Management®
48. Name the three major set of files on disk that compose a database in Oracle.
There are three major sets of files on disk that compose a database. All the files
are binary. These are
The most important of these are the database files where the actual data resides.
The control filesand the redo logs support the functioning of the architecture
itself. All three sets of files must be present, open, and available to Oracle for any
data on the database to be useable. Without these files, you cannot access the
database, and the database administrator might have to recover someor all of the
database using a backup, if there is one.
52
DATABASE MANAGEMENT SYSTEMS(BCS403)
RV Institute of Technology and
Management®
Procedures that are not part of a package are known as stand-alone because they
independently defined. These types of procedures are not available for reference
from other Oracle tools. Anotherlimitation of stand-alone procedures is that
they are compiled at run time, which slows execution.
53
DATABASE MANAGEMENT SYSTEMS(BCS403)