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

Sujal Ism File

The document provides the details of a lab practical assignment submitted by a student named Sujal for the course BBA-307 Management Information Systems at Tecnia Institute of Advanced Studies, Guru Gobind Singh Indraprastha University, Delhi. The assignment contains 11 questions related to SQL, database concepts, and creating and querying database tables. It includes the student's solutions to each question in separate sections with SQL commands and explanations.

Uploaded by

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

Sujal Ism File

The document provides the details of a lab practical assignment submitted by a student named Sujal for the course BBA-307 Management Information Systems at Tecnia Institute of Advanced Studies, Guru Gobind Singh Indraprastha University, Delhi. The assignment contains 11 questions related to SQL, database concepts, and creating and querying database tables. It includes the student's solutions to each question in separate sections with SQL commands and explanations.

Uploaded by

Geetika Gulati
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 44

TECNIA INSTITUTE OF ADVANCED STUDIES

Guru Gobind Singh Indraprastha University, Delhi

Information System
Management [ BBA-307]

LAB PRACTICAL ASSIGNMENT

Submitted in partial fulfillment of the

Requirements for the award of the degree of

BACHELOR OF BUSINESS ADMINISTRATION

Under the Guidance Submitted by


Ms. ALKA Sujal
BBA- 5TH SEM, MORNING-C
Enrollment no.: 36217001721

Session 2021-24

1
INDEX

S.NO CONTENT PAGE TEACHER’S


NUMBER SIGNATURE
1 Lab Practical Assignment 3-4
Ques
2 Solution [Ques-1] 5-6
3 Solution [Ques-2] 6-8
4 Solution [Ques-3] 8-9
5 Solution [Ques-4] 10-13
6 Solution [Ques-5] 14-22
7 Solution [Ques-6] 23-29
8 Solution [Ques-7] 29-31
9 Solution [Ques-8] 32-34
10 Solution [Ques-9] 35-36
11 Solution [Ques-10] 36-38
12 Solution [Ques-11] 38-40

2
LAB PRACTICAL ASSIGNMENT
QUES:
Q1. Write difference between DBMS and RDBMS?
Q2. What is SQL? Basics of SQL ? DDL and DML
Commands? Q3 What are different Data types in SQL
Q4. Create table STUDENT with fields: Rollno, Name, Course, DOB and
Display structure
1. modify the structure of student table
add new columns section and contact no,
city. change the size of course column by 2
points.
2. Insert 10 records.
3. Add column age . calculate age using DOB
4. Execute following queries
Display all the details of student table
Display names in alphabetical order
Display records where name starts with
'A' Display records for city 'delhi'
Q5. Create table employee: empno(PK), empname(NOT NULL),Add,
salary(NOT NULL),Designation,
Deptname,
commission Insert 5
records
Find Average and total salaries of all employees
Find minimum and maximum salary of
Manager count total no of departments
Count total no of employees in each dept
update the commission to 10% of salary for all having salary greater than
50000 and rest with
5%

3
Find the name of lowest paid
employee List average salary for all the
dept.

4
List desig and no of employees in each desig
list average salary of each desig excluding managers.
List total, Max, Min, Average salary of employees designation wise
Q6. Create table stu_details : Enroll_no, s_name,course_id,batch,semester
1. Enter 10 records
2. Execute queries
Display the list of students in batch '2017-2020'
Display the enroll_no of fourth semester
students Display the total no of students
semester wise
3. Create table course: course_id, course_name, duration
4. Enter 10 records
5. Create relationship of course with student
table Display all students enrolled in BBA course
Display name of students enrolled in 2 year course
Display details of students of BBA course of batch '2017-
2020' Q7.
1. Show records of employees whose emp_id is 101
2. Display records whose dept_name is HR and salay >10000
3. update the records set Dept_name=IT where dept_name is 'production'
4. update records of employees to increase salary by 5%
Q8. Create a table as student_marks: roll_no,sub1,sub2,sub3,sub5,sub5,total
and percentage
Enter rollno and all subject marks for 10 students
calculate total and percentage using update command
display rollno , name and total marks of the students using student
and student_marks table for
the students having percentage >80%
Q9. Explain ER diagram with their symbols used.
Q10. Create ER diagram for Library management system

5
Q11 . Create ER diagram for Employee management syste

6
LAB PRACTICAL ASSIGNMENT SOLUTIONS

Q1. Write difference between DBMS and RDBMS?


Solution 1.
A Database Management System (DBMS) and a Relational Database Management
System (RDBMS) are both software systems that manage databases. However, there
are key differences between the two:
1. **Data Structure:**
- **DBMS:** In a DBMS, data is generally stored in a hierarchical or
navigational structure. It supports a simpler structure and is less efficient in
handling complex relationships between data.
- **RDBMS:** RDBMS organizes data into tables with rows and columns. It uses
a tabular structure to represent relationships between entities, providing a more
flexible and efficient way to handle complex data.
2. **Relationships:**
- **DBMS:** It may not support relationships between tables, which makes it
less suitable for applications with complex data dependencies.
- **RDBMS:** The primary strength of an RDBMS lies in its ability to manage
relationships between tables, enforcing the integrity of the data through keys
and constraints.
3. **Normalization:**
- **DBMS:** DBMS may not enforce normalization rules, which can lead to
data redundancy and inconsistency.
- **RDBMS:** RDBMS is designed to enforce normalization rules, reducing
data redundancy and ensuring data integrity.
4. **Query Language:**
- **DBMS:** Basic DBMS may use a simple query language, and the
querying capability may be limited.
- **RDBMS:** RDBMS typically uses Structured Query Language (SQL) for
querying, which is a powerful and standardized language for managing and
manipulating relational databases.
5. **Scalability:**
- **DBMS:** Scaling a DBMS can be challenging, especially when dealing with
large amounts of data and complex relationships. - **RDBMS:** RDBMS provides
better
7
scalability, making it easier to handle a growing amount of data and more
complex database structures.
6. **ACID Compliance:**
- **DBMS:** ACID (Atomicity, Consistency, Isolation, Durability) properties may
not be fully supported in a DBMS.
- **RDBMS:** RDBMS is designed to be ACID compliant, ensuring the reliability of
transactions and maintaining data consistency.In summary, while both DBMS and
RDBMS are database management systems, RDBMS provides a more sophisticated
and structured approach to managing data, especially in applications where
complex relationships and data integrity are crucial.
Q2. What is SQL? Basics of SQL ? DDL and DML
Commands? Solution 2.
**SQL (Structured Query Language):**
SQL, or Structured Query Language, is a programming language specifically
designed for managing and manipulating relational databases. It provides a
standardized way to interact with databases, allowing users to create, retrieve,
update, and delete data. SQL is essential for anyone working with databases, as it
provides a powerful and efficient means of handling data.
**Basics of SQL:**
1. **SQL Statements:** SQL consists of a variety of statements that can
be categorized into three main types:
- **Data Definition Language (DDL):** Used for defining and managing the
structure of a database, including creating, altering, and deleting tables and
indexes.
- **Data Manipulation Language (DML):** Used for manipulating data within
the database, including querying, inserting, updating, and deleting records.
- **Data Control Language (DCL):** Involves commands for managing access
to data, such as granting and revoking permissions.
2. **SQL Queries:** Queries are used to retrieve data from one or more tables.
The basic syntax of a SELECT statement is:
COMMAND:-
SELECT column1,
column2, ... FROM table
WHERE condition;

8
3. **SQL Joins:** SQL allows you to combine rows from two or more tables based
on a related column between them. Common types of joins include INNER JOIN,
LEFT JOIN, RIGHT JOIN, and FULL OUTER JOIN.
4. **SQL Functions:** SQL provides a variety of built-in functions for performing
operations on data. Examples include COUNT(), SUM(), AVG(), MAX(), MIN(),
and more.
**DDL (Data Definition Language) Commands:**
1. **CREATE:** Used to create a new database, table, index, or
view. COMMAND:-
CREATE TABLE table_name
( column1 datatype,
column2 datatype,
...
);
2. **ALTER:** Modifies the structure of an existing database, table, or
index. COMMAND:-
ALTER TABLE table_name
ADD column_name
datatype;
3. **DROP:** Deletes an existing database, table, index, or
view. COMMAND:-
DROP TABLE table_name;

**DML (Data Manipulation Language) Commands:**


1. **SELECT:** Retrieves data from one or more
tables. COMMAND:-
SELECT column1,
column2, ... FROM table
WHERE condition;
2. **INSERT:** Adds new records to a
table. COMMAND:-

9
INSERT INTO table_name (column1, column2, ...)

10
VALUES (value1, value2, ...);
3. **UPDATE:** Modifies existing records in a
table. COMMAND:-
UPDATE table_name
SET column1 = value1, column2 =
value2, ... WHERE condition;

4. **DELETE:** Removes records from a


table. COMMAND:-
DELETE FROM table_name
WHERE condition; These commands form the foundation of SQL, and mastering
them is crucial for effectively managing and working with relational databases.

Q3 What are different Data types in SQL?


Solution 3.
In SQL (Structured Query Language), data types are used to define the type of data
that a column can hold. Each column in a table is associated with a specific data
type, and these data types help enforce data integrity by restricting the kind of
values that can be stored in a particular column. Here are some common data types
in SQL:

1. **INTEGER (INT):** Represents whole numbers without a decimal point.


Examples include 1, 100, -500, etc.
2. **SMALLINT:** Similar to INTEGER but with a smaller range of values.
3. **BIGINT:** Represents large whole numbers with a larger range than INTEGER.
4. **DECIMAL (DEC) or NUMERIC:** Represents fixed-point numbers with a
specified precision and scale. Precision is the total number of digits, and scale is the
number of digits after the decimal point.
5. **FLOAT:** Represents floating-point numbers with a decimal point. It has
a floating precision.

11
6. **REAL:** Represents single-precision floating-point numbers.
7. **DOUBLE PRECISION:** Represents double-precision floating-point numbers.
8. **CHARACTER (CHAR):** Represents fixed-length strings. You must specify
the length when defining a CHAR column.
9. **VARCHARACTER (VARCHAR):** Represents variable-length strings. You
must specify the maximum length when defining a VARCHAR column.
10. **TEXT:** Represents variable-length strings with a very large maximum length.
11. **DATE:** Represents a date in the format YYYY-MM-DD.
12. **TIME:** Represents a time of day in the format HH:MI:SS.
13. **DATETIME or TIMESTAMP:** Represents a combination of date and time.
14. **BOOLEAN:** Represents true or false values.
15. **BINARY:** Represents fixed-length binary data.
16. **VARBINARY:** Represents variable-length binary data.
17. **BLOB (Binary Large Object):** Represents large binary objects, such as
images or multimedia data.
18. **CLOB (Character Large Object):** Represents large text objects.
These data types may have variations or additional options depending on the specific
database management system (DBMS) you are using (e.g., MySQL, PostgreSQL, SQL
Server, Oracle). It's essential to refer to the documentation of the specific DBMS you
are working with for precise details on data types and their usage.

12
Q4. Create table STUDENT with fields: Roll no, Name, Course, DOB and
Display structure

1. modify the structure of student table

● add new columns section and contact no, city.

● change the size of course column by 2 points.

2. Insert 10 records

3. Add column age. calculate age using DOB

4. Execute following queries

● Display all the details of student table

● Display names in alphabetical order

● Display records where name starts with 'A'

● Display records for city 'delhi

13
ANS CREATE TABLE

OUTPUT

ADD NEW COLUMN IN TABLE OUTPUT

1
MODIFY THE TABLE

OUTPUT

INSERT RECORD

OUTPUT

1
CALCULATING AGE

OUTPUT

1
Q5. Create table employee: empno(PK), empname(NOT NULL), Add, salary(NOT NULL),
Designation, Deptname, commission

● Insert 5 records

● Find Average and total salaries of all employees

● Find minimum and maximum salary of Manager

● count total no of departments

● Count total no of employees in each dept

● update the commission to 10% of salary for all having salary greater than
50000 and rest with 5%

● Find the name of lowest paid employee

● List average salary for all the dept.

● List desig and no of employees in each desig

● list average salary of each desig excluding managers.

● List total, Max, Min, Average salary of employees designation wise

1
ANS CREATE TABLE

OUTPUT

ADD COLUMN

OUTPUT

1
INSERT RECORDS

OUTPUT

TOTAL SALARIES OF EMPLOYEE

OUTPUT

1
COUNT TOTAL NO. OF DEPTARTMENT

OUTPUT

2
COUNT TOTAL NO. OF EMPLOYEE

OUTPUT

UPDATE THE COMISSION TO 10% OF SALARY FOR ALL HAVING SALARY GRATER THAN 5000
AND REST WITH 5%

OUTPUT

2
FIND THE NAME OF LOWEST PAID EMPLOYEE

OUTPUT

LIST AVERAGE SALARY FOR ALL THE DEPT

OUTPUT

2
LIST DESIGN AND NO OF EMPLOYEES IN EACH DESIGN

OUTPUT

LIST AVERAGE SALARY OF EACH DESIG EXCLUDING MANAGERS

OUTPUT

2
AVG OF SALARY WITH DESIGNATION

OUTPUT

SUM OF SALARY WITH DESIGNATION

OUTPUT

2
MIN OF SALARY WITH DESIGNATION

OUTPUT

MAX OF SALARY WITH DESIGNATION

OUTPUT

2
Q6. Create table stu_details : Enroll_no, s_name,course_id,batch,semester

1. Enter 10 records

2. Execute queries

● Display the list of students in batch '2017-2020'

● Display the enroll_no of fourth semester students

● Display the total no of students semester wise

3. Create table course: course_id, course_name, duration

4. Enter 10 records

5. Create relationship of course with student table

● Display all students enrolled in BBA course

● Display name of students enrolled in 2 year course

● Display details of students of BBA course of batch '2017-2020'

2
Ans CREATE TABLE

OUTPUT

2
NSERT RECORDS

OUTPUT

Display the list of students in batch '2017-2020'

OUTPUT

2
Display the total no of students semester wise

OUTPUT

CREATE TABLE

OUTPUT

2
INSERT RECORDS

OUTPUT

Create relationship of course with student table

OUTPUT

3
Display all students enrolled in BBA course

OUTPUT

Display name of students enrolled in 2-year course

OUTPUT

3
Display details of students of BBA course of batch '2017-2020'

OUTPUT

Q7.

1. Show records of employees whose emp_id is 101

2. Display records whose dept_name is HR and salary>10000

3. update the records set Dept_name=IT where dept_name is 'production'

4. update records of employees to increase salary by 5%

3
ANS
Show records of employees whose emp_id is 101

Output

Display records whose dept_name is HR and salary >10000

OUTPUT

3
Update the records set Dept_name=IT where dept_name is 'production'

OUTPUT

Update records of employees to increase salary by 5%

Output

3
Q8. Create a table as student marks: roll_no,sub1,sub2,sub3,sub4,sub5, total, and percentage

● Enter roll no and all subject marks for 10 students

● calculate total and percentage using update command

● display roll no and total marks of the students using student and student marks
table for the students having percentage >80%

ANS Create a table

Output

3
Enter roll no and all subject marks for 10 students

Output

3
Calculate total and percentage using update command

OUTPUT

Display roll no and total marks of the students using student and student marks table
for the students having percentage >80%

OUTPUT

3
Q9. Explain ER diagram with their symbols used.
SOLUTION
An Entity-Relationship (ER) diagram is a visual representation of the data model that
depicts the logical structure of a database. It is widely used in database design to
illustrate the relationships between different entities in a system. The main
components of an ER diagram include entities, attributes, and relationships, each
represented by specific symbols. Here's an overview of the symbols used in ER
diagrams:

1. **Entity:**
- **Symbol:** Rectangle
- **Description:** Represents a real-world object or concept, such as a person,
place, event, or thing. The name of the entity is written inside the rectangle.

2. **Attribute:**
- **Symbol:** Oval or Ellipse
- **Description:** Represents a property or characteristic of an entity. Attributes are
written inside ovals and are connected to their respective entities. For example, if you
have an entity "Person," attributes could include "Name," "Age," and "Address."

3. **Primary Key:**
- **Symbol:** Underlined attribute
- **Description:** Indicates the attribute or combination of attributes that uniquely
identifies each instance of an entity. It is usually underlined.

4. **Relationship:**
- **Symbol:** Diamond
- **Description:** Represents an association between two or more entities. The
name of the relationship is written inside the diamond. Lines connect the participating
entities to the diamond, indicating their involvement in the relationship.

3
5. **Cardinality Notation:**
- **Symbol:** Crow's foot (for "many") or a straight line (for "one")
- **Description:** Indicates the number of instances of one entity that can be
related to the number of instances of another entity. Common cardinalities include
"one" (|) and "many" (crow's foot). For example, a line connecting a "Person" entity to
an "Address" entity with a crow's foot on the "Address" side might represent "one
person has many addresses."

6. **Weak Entity:**
- **Symbol:** Double rectangle
- **Description:** Represents an entity that does not have a primary key attribute of
its own and is dependent on another entity for identification. The double rectangle
indicates a weak entity.

7. **Inheritance/Generalization:**
- **Symbol:** Triangle (with a line connecting it to the superclass)
- **Description:** Represents an "is-a" relationship between entities, often used to
denote inheritance in object-oriented design. The superclass is the more general
entity, and the subclass is a more specific entity.

These symbols are combined in an ER diagram to visually represent the structure and
relationships within a database. The connections between entities and the cardinality
notations help convey how different entities are related to each other in the overall
data model.

Q10. Create ER diagram for Library management system


SOLUTION
Creating an Entity-Relationship (ER) diagram for a Library Management System
involves identifying and defining entities, their attributes, and the relationships
between them. Below is a simplified example of an ER diagram for a Library
Management System:

3
Entities:
1. **Book**
- Attributes: ISBN (Primary Key), Title, Author, Genre, Publication Year, Copies
Available, etc.

2. **Author**
- Attributes: AuthorID (Primary Key), Name, Birthdate, Nationality, etc.

3. **Member**
- Attributes: MemberID (Primary Key), Name, Address, Phone, Email, etc.

4. **Transaction**
- Attributes: TransactionID (Primary Key), BookID (Foreign Key), MemberID (Foreign
Key), Issue Date, Due Date, Return Date, etc.

Relationships:
1. **Authors write Books**
- One-to-Many relationship between Author and Book (an author can write multiple
books, but a book has one author).

2. **Books are available in Copies**


- One-to-Many relationship between Book and Copies (a book can have multiple
copies, but each copy belongs to one book).

3. **Members make Transactions (Borrow Books)**


- One-to-Many relationship between Member and Transaction (a member can have
multiple transactions, but each transaction is associated with one member).

4
4. **Books are involved in Transactions**
- One-to-Many relationship between Book and Transaction (a book can be part of
multiple transactions, but each transaction involves one book).

This is a basic representation, and depending on the specific requirements of your


Library Management System, you might need to add more entities and attributes or
modify the relationships accordingly. Always consider the business rules and
constraints of the system when designing the ER diagram.

Q11. Create ER diagram for Employee management system


SOLUTION
Creating an Entity-Relationship (ER) diagram for an Employee Management System
involves identifying entities, their attributes, and the relationships between them.
Here's a simplified example of an ER diagram for an Employee Management System:

Entities:
1. Employee
2. Department
3. Position
4. Project
5. Skill

Attributes:
1. Employee:
- EmployeeID (Primary Key)
- FirstName
- LastName
- DateOfBirth

4
- Gender
- ContactNumber
- Email
- HireDate
- Salary
- Address

2. Department:
- DepartmentID (Primary Key)
- DepartmentName

3. Position:
- PositionID (Primary Key)
- PositionTitle
- Responsibilities

4. Project:
- ProjectID (Primary Key)
- ProjectName
- StartDate
- EndDate
- Budget

5. Skill:
- SkillID (Primary Key)
- SkillName

4
Relationships:
1. WorksIn: - Employee (1) ------< WorksIn >------(M) Department
2. Occupies:
- Employee (1) ------< Occupies >------(M) Position

3. AssignedTo:
- Employee (M) ------< AssignedTo >------(M) Project

4. Possesses:
- Employee (M) ------< Possesses >------(M) Skill

This ER diagram represents the relationships between entities in an Employee


Management System. The notation used includes crow's foot symbols to indicate the
"many" side of relationships, and lines to connect related entities. The primary keys
are also specified for each entity.

Keep in mind that this is a simplified representation, and in a real-world scenario, you
might need to consider additional details and constraints. The actual requirements of
your Employee Management System may vary, so adjust the entities and attributes
accordingly based on your specific needs.

4
4

You might also like