Sie sind auf Seite 1von 12

www.khoji.

net MCS-023 SOLVED ASSIGNMENT FOR BCA/MCA

KHOJI.NET
Page 1

Like Our Facebook Page For Regular Updates facebook.com/khojinet


www.khoji.net MCS-023 SOLVED ASSIGNMENT FOR BCA/MCA

KHOJI.NET
Page 2

Like Our Facebook Page For Regular Updates facebook.com/khojinet


www.khoji.net MCS-023 SOLVED ASSIGNMENT FOR BCA/MCA

Question 1. List and describe briefly all the possible applications of a database
management system for a University.

Answer: Storing and accessing the data in the form of Excel sheets and account books is a
tedious work. It requires a lot of laborious work. It may often yield undesired results.
Maintaining these records as files may turn out to be a costlier task than any other of the
colleges and institutions.

A Database management system is a computerized record-keeping system. It is a repository or a


container for collection of computerized data files. The overall purpose of DBMS is to allow the
users to define, store, retrieve and update the information contained in the database on demand.

KHOJI.NET
Information can be anything that is of significance to an individual or organization.

Applications of DBMS for a University:

1. Used to store student data in single place: We know Database is used for storing Data
and Information. In a University DBMS cn be used to store all the data related to students
in one place. Instead of keeping different files for different records all the related data can
be stored in single database.
2. Used for multiple access: Because of facility of DBMS data can be accessed by multiple
users. This access can be simultaneously. With the help of DBMS multiple users can
work on the database. This will help to finish work more fast.
3. Can be centeralized: With the help of a centralized database all the branches of
university can access data any time. This facility is not present in manual/traditional
system.
4. Online use: With the help of DBMS database can be available online via internet. This
will facilitate every user of the database. Students can benefit most from it because they
can access their details online.
5. Online Registration: By going to online DBMS option University will get facility of
online registration, where students can register online without visiting University.
6. Online results: With the help of online DBMS results can be declared online every
student will have instant access to their result via visitng result page.
7. Various online forms: Various forms such as registration form, change information form
or any other request form can be put online. All the form data will be stored in database.
8. Live tracking: With the help of DBMS all the process can be tracked properly. It is very
hard in physical filing system.
Page 3
9. Easy query: DBMS will help querying data more fast. Any type of data can be accessed
instantly with just a single query.
10. Easy Analysis: With the help of DBMS all the data will be stored computerized. This
data can be used for different kind of analysis. Analysis purpose is the biggest use of
DBMS in any industry. For example comparing current year results with previous or

Like Our Facebook Page For Regular Updates facebook.com/khojinet


www.khoji.net MCS-023 SOLVED ASSIGNMENT FOR BCA/MCA
students enrolled, fee collection etc. All this analysis can be done in just few minutes
with the help of DBMS.
11. Use in Library: DBMS can be used in libararies of Universities to keep easy record of
all the data.
12. Can be used to record salaries data of faculty: DBMS can be used to store all the data
of salaries paid to faculties. Every calculation of salary can be done automatically by
computer.
13. For Attendance Data: Universities can use DBMS to store attendance data of students
as well as all other faculties. This will ensure reliability of data as well as saftey.
14. 24x7 Support and other facilities: By using DBMS all the data can be provided online

KHOJI.NET
through a website. In case any student or faculty member need any data it will be
available. For students it would be a 24x7 support system.

Page 4

Like Our Facebook Page For Regular Updates facebook.com/khojinet


www.khoji.net MCS-023 SOLVED ASSIGNMENT FOR BCA/MCA

Question 2. Identify all the associated entities for a University Management System, their
corresponding attributes, relationships and cardinality and design an Entity-Relationship
(ER) diagram for it.

Answer:

ER Diagram:

KHOJI.NET
Page 5

Like Our Facebook Page For Regular Updates facebook.com/khojinet


www.khoji.net MCS-023 SOLVED ASSIGNMENT FOR BCA/MCA

Question 3. Consider the E-R diagram of Question 2 and design the relational schema and
the tables. Perform and show the Normalization till the required normal form. Implement
the database using MS-Access and submit the screenshots along with your assignment
response for this question.

Answer:

KHOJI.NET
Page 6

Like Our Facebook Page For Regular Updates facebook.com/khojinet


www.khoji.net MCS-023 SOLVED ASSIGNMENT FOR BCA/MCA

KHOJI.NET
Page 7

Like Our Facebook Page For Regular Updates facebook.com/khojinet


www.khoji.net MCS-023 SOLVED ASSIGNMENT FOR BCA/MCA

KHOJI.NET
Question 4. Consider the following relations:

Supplier(S#,sname,status,city)

Parts(P#,pname,color,weight,city)

SP(S#,P#,quantity)

Answer the following simple queries in SQL.

We will be using s_id instead of S# and P_id instead of P#

a) Find name of supplier for city = “MUMBAI”.

Answer: SELECT sname FROM Supplier WHERE city=”MUMBAI” ;

b) Find suppliers whose name start with “AD”

Answer: SELECT * FROM Supplier WHERE name LIKE “AD%” ;


Page 8

c) Find all suppliers whose status is 10, 20 or 30.

Answer: SELECT * FROM Suppliers WHERE status=10 OR status=20 OR status=30 ;

Like Our Facebook Page For Regular Updates facebook.com/khojinet


www.khoji.net MCS-023 SOLVED ASSIGNMENT FOR BCA/MCA

d) Find total number of city of all suppliers.

Answer: SELECT COUNT(DISTINCT city) FROM Suppliers ;

e) Find s# of supplier who supplies „BLUE‟ part.

Answer: SELECT s_id FROM SP WHERE P_id IN (SELECT P_id FROM Parts WHERE
color=”BLUE” ;

KHOJI.NET
f) Count number of supplier who supplies „BLUE‟ part.

Answer: SELECT COUNT(DISTINCT s_id) FROM SP WHERE P_id = (SELECT P_id


FROM Parts WHERE color=”BLUE” ) ;

g) Sort the supplier table by sname.

Answer: SELECT * FROM Supplier ORDER BY sname ASC ;

h) Delete records in supplier table whose status is 40.

Answer: DELETE FROM Supplier WHERE status=40 ;

i) Find name of parts whose color is „red‟

Answer: SELECT pname FROM Parts WHERE color=”red” ;

j) Find parts name whose weight less than 10 kg.

Answer: SELECT pname FROM Parts WHERE weight<10 ;


Page 9

k) Find all parts whose weight from 10 to 20 kg.

Answer: SELECT pname FROM Parts WHERE weight BETWEEN 10 AND 20 ;

Like Our Facebook Page For Regular Updates facebook.com/khojinet


www.khoji.net MCS-023 SOLVED ASSIGNMENT FOR BCA/MCA

l) Find average weight of all parts.

Answer: SELECT AVG(weight) FROM Parts ;

m) Find S# of supplier who supply part „p2‟

Answer: SELECT S_id FROM SP WHERE P_id IN (SELECT P_id FROM Parts WHERE
Pname=”p2” ) ;

KHOJI.NET
n) Find name of supplier who supply maximum parts.

Answer: SELECT Supplier.Sname FROM Supplier WHERE Supplier.S_id = (SELECT


SP.S_id FROM SP GROUP BY SP.S_id HAVING COUNT(SP.P_id) ORDER BY
COUNT(SP.P_id) DESC LIMIT 1) ;

o) Sort the parts table by pname.

Answer: SELECT * FROM Parts ORDER BY pname ;

Question 5. Consider a toy-store database has the following schema:

Product(pid: integer, name: varchar(20), min_age: integer)

Manufacturer(mid: integer, name: varchar(20), address: varchar(50))

Supplier(sid: integer, name: varchar(20), address: varchar(50))

Inventory(pid:integer, stock: integer)

Manufactures(mid:integer, pid: integer)


Page 10
Supplies(sid: integer, pid: integer)

Write and run the following SQL queries on the tables:

Like Our Facebook Page For Regular Updates facebook.com/khojinet


www.khoji.net MCS-023 SOLVED ASSIGNMENT FOR BCA/MCA

a) Find all the product_id‟s and names whose manufacturer is LEO company.

Answer: SELECT Product.pid, Product.name FROM Products WHERE Products.pid


IN(SELECT Supplies.pid FROM Supplies WHERE Supplies.sid = (SELECT Supplier.sid
FROM Supplier WHERE Supplier.name="LEO"));

b) Find all the Supplier details who supplies police_car toy.

Answer: SELECT * FROM Supplier WHERE sid = (SELECT sid FROM Supplies WHERE
pid = (SELECT pid FROM Product WHERE name = “police_car” ;

KHOJI.NET
c) Write a SQL statement to insert a new product with pid=-1, name='my product', and
min_age=3 into the Product table.
Answer: INSERT INTO Product(pid, name, min_age) VALUES(-1, “my product”, 3);

d) List the ids and names of all products whose inventory is below 10.

Answer: SELECT pid, name FROM Product WHERE pid IN (SELECT pid FROM Inventory
WHERE stock < 10) ;

e) List the ids and names of all suppliers for products manufactured by "TRIKA". The id
and name of each supplier should appear only once.

Answer: SELECT DISTINCT Supplier.sid, Supplier.name FROM Supplier WHERE


Supplier.sid IN (SELECT Supplies.sid FROM Supplies WHERE Supplies.pid IN (SELECT
Product.pid FROM Product WHERE Product.pid IN (SELECT Manufactures.pid FROM
Manufactures WHERE Manufactures.mid = (SELECT Manufacturer.mid FROM
Manufacturer WHERE Manufacturer.name=”TRIKA”))));

f) List the ids, names, and number in stock of all products in inventory. Order the list by
decreasing number in stock and decreasing product ids.
Page 11

Answer: SELECT Product.pid, Product.name, Inventory.stock FROM Product LEFT JOIN


Inventory ON Inventory.pid = Product.pid ;

g) List the ids and names of all products for whom there is only one supplier.

Like Our Facebook Page For Regular Updates facebook.com/khojinet


www.khoji.net MCS-023 SOLVED ASSIGNMENT FOR BCA/MCA
Answer: SELECT pid, name FROM Product WHERE pid IN (SELECT DISTINCT pid
FROM Supplies WHERE COUNT(DISTINCT sid) = 1) ;

SELECT Product.pid, Product.name FROM Product WHERE Product.pid IN (SELECT


Supplies.pid FROM Supplies GROUP BY Supplies.pid WHERE COUNT(sid) = 1) ;

h) Find the ids and names of the products with the lowest inventory. Do NOT assume these
are always products with an inventory of zero.

KHOJI.NET
Answer: SELECT Product.pid, Product.name, MIN(Inventory.Stock) FROM Product
INNER JOIN Inventory ON Inventory.pid=Product.pid ;

i) List the id and name of each supplier along with the total number of products it supplies.

Answer: SELECT Supplier.sid, Supplier.name, Supplies.num FROM (SELECT


COUNT(Supplies.pid) AS num FROM Supplies GROUP BY Supplies.sid FROM Supplies)
Supplier, Supplies ;

j) Find the id and name of the manufacturer who produces toys on average for the
youngest children.

Answer: SELECT Manufacturer.mid, Manufacturer.name FROM Manufacturer WHERE


Manufacturer.mid = (SELECT Manufactures.mid FROM Maufactures WHERE
Manufactures.pid = (SELECT Product.pid FROM Product WHERE Product.min_age =
AVG(Product.min_age) LIMIT 1)) ;

Page 12

Like Our Facebook Page For Regular Updates facebook.com/khojinet