0% found this document useful (0 votes)
275 views10 pages

Spreadsheet& RDBMs

This document discusses advanced electronic spreadsheets and contains questions related to various spreadsheet features and functions including data analysis tools like scenarios, goal seek, solver and data consolidation. It also includes questions on creating macros, hyperlinking between worksheets and workbooks, and sharing and collaborating on spreadsheets.

Uploaded by

Pushpa devi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
275 views10 pages

Spreadsheet& RDBMs

This document discusses advanced electronic spreadsheets and contains questions related to various spreadsheet features and functions including data analysis tools like scenarios, goal seek, solver and data consolidation. It also includes questions on creating macros, hyperlinking between worksheets and workbooks, and sharing and collaborating on spreadsheets.

Uploaded by

Pushpa devi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Unit 2: Electronic Spreadsheets – (Advanced)

All Exercises are practical oriented.

Assessment
A. Select the correct option. – 1 Marks each.
1. C 2. C 3. B 4. D 5. A 6. C 7. B
8. B 9. A 10. B 11. C 12. C 13. C 14. A
15. B 16. A 17. C 18. B 19. B 20. C 21. C
22. A 23. B
B.Answer the following questions – 2 marks each
1. What is the significance of sub-total feature in a spreadsheet?
Subtotals feature is a quick way to calculate automatic subtotals, averages and other numeric summary on a group
of data. Subtotals works better on the sorted data. Some examples are: class-wise total marks, depart-wise average
salary, city-wise population count etc.
2. Briefly describe a scenario/example where data consolidation is useful.
Data consolidation feature allows us to bring together data from different spreadsheets and workbooks into a
consolidated form where various calculations are done on the data values. For example, if 4 separate workbooks
contain the marks of students in 4 different sections of a class then this feature can be used to consolidate marks
of all sections to calculate average performance whole class.
3. Anu has two sets of 10 marks each which she wants to apply on a dataset to analyse the output to improve
students’ performance in next exam. Write steps to help Anu apply these 2 sets of scenarios one by one.
First, select all the marks in first data. Go to Tools menu > Scenarios option. In the Create Scenarios dialog box,
mention the name of the scenario (e.g., MARKLIST1) and click OK. Repeat the same for MARKLIST2. Now Anu can
select different scenarios form the drop-down to observe and analyse the changing values.
4. What do you mean by Formula cell, Target value and Variable cell in Goal Seek?
Formula cell is the address of that cell that contains the formula to perform desired calculation.
Target value contains the expected output value.
Variable cell is the address of the cell whose value should change to get expected output value.
5. How can you say that Solver is an advanced form of Goal Seek tool?
Solver is an advanced form of goal seek in that it estimates the optimised values on the basis of multiple input
values while in goal seek there is only one input value. Solver also considers certain constraints if any are given.
Solver works on certain optimisation algorithms.
6. Why do we need the data sorted before applying sub-total feature on it?
Subtotal displays aggregate calculations on the group of data based on similar values of a field. So, the data needs
to be sorted on that field for correct grouping.
7. How is Scenario feature different from Goal-seek? Explain with a small example each.
Scenario allows us to input a set of multiple values to observe the changes in output while in goal seek, we work
with single value for the desired output.
8. Ajit has 3 sets of sales data which he wants to apply on the actual data to see how much earning his company
will do in the end of the month. Which “what-if” analysis feature will be suitable for him and why?
In this situation, Scenario feature is useful because Scenario feature allows us to input a set of multiple values to
observe the changes in output
9. Ajit wants to know how much savings are needed to be done in current month to keep his expenses at Rs.
100000 by month end. Which “what-if” analysis feature will be suitable for him and why?
The goal seek feature is most suitable in this situation since there is only single input value and single desired
output. Goal seek tells us the input needed to get the desired output.
10. How is relative path different from absolute path?
Absolute path includes the original file path from the root of the storage while relative path excludes the common
path to the file.
11. What is the advantage of relative hyperlinking?
Since relative hyperlinking works on the relative path which excludes the common original path to the file, it is
74
useful when the linked files are to be distributed to others along with the main file. User can copy the distributed
folders anywhere on the computers and hyperlinks will not break.
12. In a formula, how will you refer to a cell B5 in a sheet named mysheet1?
mysheet1!B5
13. In a formula, how will you refer to a cell B5 in a sheet named mysheet1 in a workbook named myworkbook?
[myworkbook.xlsx]mysheet1!B5
14. What do you mean by registered data source?
A data source about which the application software is aware of its location and how to connect with it is called
registered data source.
15. Why do we need to share documents?
In an online collaborative environment such as cloud drive or network drive, users can work on the same document
through sharing feature. This saves time and effort in maintaining and updating multiple copies and minimises
errors.
16. What is the advantage of tracking changes in a shared document?
In a collaborative setup where multiple users are changing the same document, it is necessary to track who has
made what changes so that desired changes can be applied and rest can be rejected.
17. What actions can you take on the changes done by other users in a shared document?
We can either accept all changes, reject all changes, accept selective changes or reject selective changes.
18. What is the basic difference between track changes comments and general comments?
Q no. 18 - Answer missing
19. How is a function different from a sub-procedure?
A function returns a value after execution while a sub-procedure does not. A function can be used like any other
function by its name while a sub-procedure is invoked from a keystroke or menu option.
20. How does a function return a value? Give example.
When we assign a value to be returned to a variable of the same name as that of function. E.g.
function myfunc()
‘this function returns 0
myfunc=0
end function
21. What is function argument? Give example.
When a function needs the values to be processed while it is invoked then the required values are passed as
arguments to the function. E.g., addTwo(5, 19) here, 5 and 19 are arguments passed to addTwo() for processing.
22. Write the statement to store value 10 in cell A1.
ThisComponent.Sheets(0).getCellByPosition(0, 0).setValue(10)
23. Write a macro to copy value of one cell to another.
This will copy value of cell B1 to cell A1:
Sub doCopy()
v = ThisComponent.Sheets(0).getCellByPosition(1, 1).getString()
ThisComponent.Sheets(0).getCellByPosition(0, 1).setString(v)
End Sub
24. Implement a loop to display values 1 to 20 in reverse.
This will display values 20 to 1 from cell A2 till A21
Sub show()
y=0
For x = 20 To 1 Step -1
ThisComponent.Sheets(0).getCellByPosition(0, y).SetValue (x)
y = y + 1
Next
End Sub

75
C.Answer the following questions – 3 marks each.
1. With a small example, explain how Solver is a better tool than Goal Seek in certain scenarios.
Goal seek tells us the input required to achieve a desired output. Solver works on certain algorithms to estimate
the optimised inputs to get the desired output while considering any constraints given along with. E.g., if we need
to know how many marks need to be gained in a subject to achieve over all 90% then Goal Seek is suitable but if we
need to minimise salary expenses of 100 employees while constraint is that each employee should get a minimum
amount then Solver is required.
2. What is the advantage of data consolidation?
Data consolidation feature is useful when there are separate copies of data on which some calculations need to
be done. For example, if four sheets store the sales data in same layout then the figures can be summed up in a
separate sheet using data consolidation feature.
3. Describe the syntax of referring to a cell in another worksheet.
To refer to a cell which is in another sheet, we need to tell the application the name of the sheet and the cell
address in that sheet. The sheet name is mentioned first followed by an ! sign and then the desired cell address.
For example, Worksheet_name!cell_address – if sheet name is Sale_June and cell address is A5 then Sale_June!A5.
4. What do you mean by base path in hyperlinking? What is the limitation of absolute linking?
Absolute linking contains the original path right from the root of the storage and when we copy the files to another
computer the path does not update according to the new location. Relative referencing works considering the
common path of linked files and the main file. The common path is called base path which is excluded in relative
linking. This way, files can be distributed and copied to any computer and hyperlinking works.
5. How is relative linking a better way than absolute linking?
Refer to question 4.
6. Roma has saved Index.doc on path D:\my stories\fiction\2020. Index.doc contains relative hyperlinks,
one for each of the chapter in the story. All the chapters are in separate files named as Chapter_x.doc,
where x is the chapter number. All the chapters are on path D:\my stories\fiction\2020\pdf\draft. Which
folder should she send to the publisher so that all the links work fine on publisher’s computer too and
why?
Files are linked relatively that means common base path D:\my stories\fiction\2020 is excluded in linking and
only path /pdf/draft is used for linking. The path will be resolved from folder 2020 onwards so Roma should give
folder pdf to the publisher. No matter where the files are copied, the relative path /pdf/draft will work.
7. How will you link a worksheet to a defined name in another sheet in the same workbook?
Go to Sheet menu > Link to External Data option. In the dialog box, Click Browse to locate the target file. It will
display the names of all the data ranges in that file. Select the desired range and click OK.
8. What are the advantages of sharing a file over a cloud location?
In an online collaborative environment such as cloud drive or network drive, users can work on the same document
through sharing feature. This saves time and effort in maintaining and updating multiple copies and minimises
errors. Another advantage is the cost is minimised and work is done efficiently.
9. Atul has 4 worksheets of data from different branches of his company. All have identical layout. He needs
to merge them into one sheet. How will he do that?
Atul will use Compare and merge feature of spreadsheet application. To merge the 4 worksheets, Atul will first
open the first worksheet. Then, he will click on Edit menu > Track Changes > Merge Document. In the dialog box,
locate and select the files need to be merged. Then. Click on Open button. In Manage Changes dialog box, accept or
reject changes as you need and click Close.
10. What is the benefit of macros? How will you create and run a macro in a spreadsheet application?
In real life, people perform a lot of routine tasks on a fixed layout of data-set. In such scenarios, macros help in
saving a lot of time and effort. This way, macros are used to automate routine tasks. For example, performing
multiple complex calculations using several formulas daily on the data stored in same layout. For this, a macro can
be created to execute calculations automatically in a few seconds. To create a macro, go to Tools menu > Macros
> Record Macro option. The recording will begin. Perform the steps to be recorded and click on Stop Recording
button in the popup.
D.Answer the following questions – 5 marks each.
1. Briefly describe the different ways of what-if analysis using a spreadsheet.
Major 3 ways of what-if analysis are given here:
Scenario: Scenario is a way to perform what-if analysis. A scenario is defined by a set of values which can be
76
applied on an existing data-set. Various scenarios can be created and applied on the original data-set to analysis
different situations predicted in the scenario. This way, user can analyse different business scenarios by using
Scenario feature. As you select different scenarios, you can observe and analyse the changing values.
Goal Seek: Goal seek allows us to determine the input for a desired output. For example, how many more students
should have scored 70% to make class average 75%? Or, how many more five stars were needed for a web site to
have its rating above 8? In goal seek, you need to specify 3 items – which cell you want changed, by which value
(expected output) and which cell has the input value.
Solver: Solver is a more advanced tool than Goal Seek. It is used to find out best optimised results from the data
by considering certain constraints. For example, maximizing the profits, minimising the expenses, estimating
optimum budget etc. Solver analyses the values and constraints to provide the best possible solution.
2. How is data consolidation different from sheet comparison?
Data consolidation is used to perform combined calculations on different sheets and take out a summary of all the
figures while comparison is done to check the changes done by multiple users in multiple copies of a sheet.
Data Consolidation allows us to bring together data from different spreadsheets and workbooks into a consolidated
form where sum or average or other calculations are done on the data values. Let us see a simple example. Sheets
named East Sale and West Sale need to be consolidated as their average in sheet Average Sale.
If there are multiple copies of same worksheet modified by multiple users then all of them need to be compared to
check the data changes. Sometimes users forget to enable tracking of changes and changes made by them are not
recorded. In such a case, you can compare the original document and changed document.
3. Describe a scenario where Solver is the best choice to apply.
A furniture company manufactures 4 types of items namely Table, Chair, Sofa and Bed. The billing of items is done
on credit and details of billing amount are recorded. Then, an estimate of expected amount to be collected is taken
as 80% of the billing amount. The owners want to know - How much billing of each item is needed to collect
expected amount of Rs. 100000000 but for each subject, the billing amount should be at least Rs. 30000000?
4. How will you ensure that documents hyperlinked with the sheet are linked relatively?
To set up and insert relative hyperlinks, go to the Tools menu > Options option.
In the Options dialog box, go to Load/Save > General and check “Save URLs relative to file system” and “Save URLs
relative to internet” check boxes. Click OK.
To insert a hyperlink into the spreadsheet do any of these:
Go to the desired cell or select the desired text. Then, Insert menu > Hyperlink option, or,
Click the Insert Hyperlink button on the Standard toolbar, or,
Drag-drop an item from the Navigator to the desired cell, or,
Type the target web address or URL or path to the target document at the point where you want to insert the
hyperlink.
5. Manoj has details of employees in a table Employee_Master in a database named CompanyDB.odb. How
will he link the data in his worksheet?
To link the database table data with the spreadsheet, do the following:
Go to, Tools menu > Options. In the Options dialog box, go to LibreOffice Base > Databases.
Registered databases will be listed.
Click on New button to locate the database to be registered and click OK on Create Database Link popup.
Finally click OK in Options dialog box.
To link the registered database, go to View menu > Data Sources option. Registered data sources will be listed
in the Data Source Window. Navigate to the desired database and table in it. Select the whole table by clicking in
top-left blank grey cell. Then, drag-drop the table to the sheet or click on Data to Text button in the Table Data
toolbar.
Update any changes in the data in data source by selecting the data range in the sheet and using Data menu >
Refresh Range option.
6. Write a brief note on various types of comment in spreadsheet.
Comments are another way of reviewing documents. Users can suggest changes by adding popup comments to
the cells in the sheet. Calc provides two types of comments - comments on changes and general comments. Track
changes comments are added to the changed cells and appear in the Manage Changes dialog box while reviewing
the sheet but general changes do not.
To add/edit comments on changes in the selected cell, go to Edit menu > Track Changes > Comment option.
77
To add general Comments, right click on the cell > Insert Comment option or go to Insert menu > Comment option.
General comments are indicated by a red dot in the top-right corner of the cell.
General comments can be formatted like text and graphics.
7. Anuj has a worksheet in a particular format. A copy of same sheet is with his assistant. They both made
certain changes in their copies. How will Anuj keep his changes as well as accommodate assistant’s changes
also in his sheet? Write detailed steps.
If there are multiple copies of same worksheet modified by multiple users then all of them need to be merged into
the original sheet. In such a case, Anuj can compare his document and assistant’s document.
To merge the worksheets, Anuj must first open his worksheet. Then, go to Edit menu > Track Changes > Merge
Document option.
In the Merge With dialog box, select the assistant’s file whose data needs to be merged and click on Open button.
Manage Changes dialog box will appear. Accept/Reject changes as you need and click Close. The sheet will be
merged.
8. Consider this sheet named Employee and write macro to sort the data on the basis of department in
ascending order.
Sub Dosort
Dim sortfields(1) As New com.sun.star.util.SortField
Dim sortdesc(0) As New com.sun.star.beans.PropertyValue
sheet = ThisComponent.Sheets.getByName(“Employee”)
range_to_sort = sheet.getCellRangeByName(“A2:C7”)
ThisComponent.getCurrentController.select(range_to_sort)
sortfields(0).Field = 1
sortfields(0).SortAscending = TRUE
sortdesc(0).Name = “SortFields”
sortdesc(0).Value = sortfields()
range_to_sort.Sort(sortdesc())
End sub
9. Referring to the sheet Employee, write macro to sort data on department in ascending order and basic
salary in descending order under it.
Sub Dosort
Dim sortfields(1) As New com.sun.star.util.SortField
Dim sortdesc(0) As New com.sun.star.beans.PropertyValue
sheet = ThisComponent.Sheets.getByName(“Employee”)
range_to_sort = sheet.getCellRangeByName(“A2:C7”)
ThisComponent.getCurrentController.select(range_to_sort)
sortfields(0).Field = 1
sortfields(0).SortAscending = TRUE
sortfields(1).Field = 2
sortfields(1).SortAscending = FALSE
sortdesc(0).Name = “SortFields”
sortdesc(0).Value = sortfields()
range_to_sort.Sort(sortdesc())
End sub
10. Referring to the sheet Employee, write a function to return average of all basic salary values.
Function getAvgBasic()
total = 0
avg = 0
range = ThisComponent.Sheets(0).getCellRangeByName(“C2:C7”)
rows = range.getData()

78
For x = LBound(rows) to UBound(rows)
total = total + rows(x)(0)
Next
avg = total/6
getAvgBasic=avg
End Function
11. A worksheet has some values with font colour blue and cell fill colour yellow. Write steps to create a macro
to copy-paste only the values of these cells to another location in the same sheet. (Hint: Use paste-special
while pasting the data).
Go to Tools menu > Options option > In Options dialog box, LibreOffice > Advanced and select Enable macro
recording (may be limited) checkbox. Then, click OK.
Now, go to Tools menu > Macros > Record Macro option. The macro will begin recording with a popup containing
Stop Recording button.
Select the desired cells and press Ctrl+C.
Go to the target cell, right click and select Paste Special > Text.
Click on the Stop Recording button in the popup.

Unit 3: Database Management System


Note: The sessions that have lab exercises are not mentioned here. Students must solve them in the lab as practical
implementation.

SESSION 2: Data Storage


1. Research-based. Students must do it themselves.
2. Varchar or char is most suitable since on these numbers no arithmetic is needed so no need to take them as numeric.
3. To store various types of values such as number, text, dates, currency values, binary data we need to have different types
of fields in a database.
4. Form is used to display and manipulate data while reports display the data in a formal format for analysis.
5. Tables store all the data. Rest of the operations follow when data is there in the tables.
6. Primary cannot be null and it identifies the records uniquely while foreign key can be null and it refers to the primary
key in parent table.

Assessment
A. Select the correct option. – 1 Marks each.
1. C 2. B 3. D 4. A 5. A 6. B 7. C
8. C 9. D (Both a) and b)) 10. D 11. D 12. A 13. B
14. D 15. D 16. A 17. A 18. D 19. D 20. B
21. D 22. D 23. A 24. C 25. B 26. A 27. C
28. B 29. C 30. C 31. D 32. B 33. B 34. C
35. D 36. A
B.Answer the following questions – 2 marks each
1. What is data?
Data is raw piece of information that alone does not make sense. It can be any value such as, name of a person, a
number, images, sound, etc. For example, Ravi, 4, student, etc.
2. What is information?
When the data is processed and converted into a meaningful and useful form, it is known as information.
For example, Ravi is 4 years old and he is a student. is information.
3. What do you mean by the terms database and DBMS?
A database is a collection of related data from which users can efficiently retrieve the desired information.
A database can be a simple collection of text data in a simple tabular form to a complex collection of images, audio
or video.
79
DBMS is a collection of programs that enables users to create, maintain database and control all the access to the
database. The primary goal of the DBMS is to provide an environment that is both convenient and efficient for user
to retrieve and store information.
4. List any 2 advantages of a database.
i. Security: To prevent unauthorized access to the database, DBMS uses features like encryption, authentication,
authorization and views to provide security to the database.
ii. Data Integrity: Data integrity is a set of rules that DBMS provides to see that data incorrect or inconsistent
data is not stored.
5. In two lines, explain how databases help businesses.
Almost all the small, medium and large businesses of all kinds need to manage their data and for that they use
databases. Database help them manage the data related to day-to-day operations, employees, finances, and
customers etc.
6. What is RDBMS?
Relational databases are more widespread than the flat file database alternatives. Relational databases break up
the single table of flat file database model. Therefore, relational databases are split up into multiple database tables
with methods for the tables to work together. These tables then need to be linked in some way by the database
designer. Links are established with primary and foreign keys which are unique identifiers for the database tables.
7. What is relation in a database?
The tables that store the data about any entity or event are called relations. Each relation is described by some
attributes which are represented by fields and each set of data is considered as a record in the relation.
8. What is the use of database forms?
In databases, it is possible to use forms for the creation, display and modification of records. Data entry in a form
is visually easier to understand than in a table, and is simpler for the user. Forms may contain fields for data entry,
field descriptions (names), action buttons, menus, pictures, and design elements.
9. What is the significance of database reports?
Reports present the information stored as data in the database in a form easy to understand and analyse. Reports
are meant for the executives and managers who need to analyse the status of various affairs in the business help
take decisions. Reports help in this.
10. How query helps in retrieving information from the data stored in the database?
Using a query, we mention the fields which store the data we need and we also mention the criteria in the query
to filter out the desired records as per our requirements. Query can relate multiple tables on the basis of common
fields and take out the desired data.
11. How is VARCHAR is different from CHAR data type in a database?
CHAR text (fix): Stores exactly the length specified by user. Pads with trailing spaces for shorter strings. Accepts
any UTF 8 Character.
VARCHAR (text): Stores up to the specified length. No padding (Same as long var char)
12. What is the relation between a foreign key and a primary key?
Primary key uniquely identifies each record in the table. Primary key consists of a single attribute or multiple
attributes in a combination.
The foreign key is the field in the child table that refers to a matching value in a column in another table (parent).
It cannot contain the values other than that column. It can contain the duplicate values also.
13. List any two commands of DDL and DML each.
DDL commands:
CREATE TABLE “Sales”
(
“ITEM_CODE” Varchar(4),
“SALE_DATE” Date,
“QTY_SOLD” Numeric(5)
);
Alter table “Sales” add Particulars varchar(200) after QTY_SOLD
DML commands:

80
Delete from “Item” where PRICE < 700;
Update “Item” set “ITEM_TYPE” = ‘STRETCH’ where “ITEM_TYPE”=’STRETCHABLE’;
14. Why do we need a transaction or child table?
If we keep all the data in a single table then it will lead to data redundancy and it will be difficult to manage the
data such as insert/delete. To avoid these problems, we break the table into multiple and relate them on common fields.
15. Mention the use of any two field properties of a table.
Default value property ensure a pre-set value to be stored in the table if user skips data entry in it.
Entry required is like not null constraint that ensures that the field does not remain empty.
16. How will you set a primary key in a table?
Right click on the desired field name in Table Design View and select Primary key option.
17. Give two basic differences between table data view and table design view.
Table design view allows the user to define the structure of the table in terms of various fields and field properties.
User sets up primary key in this view also.
Data view displays the data stored in the table and user can work with it by inserting, deleting and modifying.
18. Write SQL statement to create a table Person to store Full Name, Birth Date, email ID and City. Email ID is
primary key.
CREATE TABLE person(fullname varchar(100) not null, BirthDate date, emailID varchar(100) primary key, city
varchar(100))
19. How will you sort data in a database table?
In Table Datasheet View, select the desired table and click on Sort Ascending or Sort Descending buttons in the
Table Data toolbar.
20. What do you mean by referential integrity?
Referential integrity is the concept to ensure that accurate and consistent data is maintained in the database
tables which are related such as value entered in foreign key in child table must match a primary key value in the
parent table.
And, updates and deletes of unwanted data should not be done.
21. List one example of 3 types of relationship each.
One-to-one: One passenger is allocated one seat in the train.
One-to-many: A PNR identifies many passengers in a train journey.
Many-to-many: Many teachers teach many students.
22. What is a wildcard? Mention 2 examples of wildcard.
A wildcard is a shortcut to specify value patterns that are shared by multiple values in a table. For example, to
display the details of all the employees whose names begin with letter ‘P’ is represented as LIKE ‘P*’ which means
any number of occurrences of any letter. Or, details of those city names have exactly 7 characters then we can use
? wildcard which means exactly one letter as LIKE ‘???????’.
23. How will you group data on a field in query design view?
In the Query Design View, drag-drop the desired field from the table field list down to the Field section of the grid.
Then, below that field, in Function section, select Group option from the drop-down.
24. What do you mean by control properties?
Usually a graphical component used to create form interface for user interaction is called control such as
textbox, listbox, checkbox, button etc. Property defines the look and functionality of the control such as Font,
BackgroundColor, control will be Enabled or not, control will be visible or not etc.
C.Answer the following questions – 3 marks each
1. What is the significance of a database?
Database approach came into existence due to the drawbacks and limitations of file processing system. In file
processing systems; updating, deleting and maintaining the data is difficult. In the database approach, the data is
stored at a central location and is shared among multiple users. Thus, the main advantage of DBMS is centralization
of data. Databases also reduce data redundancy.
2. Briefly discuss any 2 major advantages of a database.
i. The ability to update and retrieve data: This is the fundamental feature of a DBMS. Without the ability to view
or manipulate data, there would be no point to using a database system. Updating data in a database includes
adding new records, deleting existing records and changing information within a record.
81
ii.
Support Concurrent Updates: Concurrent updates occur when multiple users make updates to the database
simultaneously. Supporting concurrent updates is also crucial to database management as this ensures that
updates are made correctly. Otherwise, it would lead to the loss of important data and/or inaccurate data
stored.
3. How database can help a school like yours?
Let the students answer this by discussing with the teacher.
4. What is the basic difference between the structure of a flat file system and relational database?
Flat file is a database with one database table. One single database table can include all the database’s fields.
Relational databases are split up into multiple database tables with methods for the tables to work together.
These tables then need to be linked in some way by the database designer. Links are established with primary and
foreign keys which are unique identifiers for the database tables.
5. In one line, define the terms table, query, form and report.
A Table is a collection of data related to an entity or event.
A query is used for selection of information from one or several tables.
Forms allow to insert new data, display data and modification of records in a table besides viewing the data.
Reports are the formal presentation of desired data as information to analyse and make decisions.
6. What is the significance of foreign key and primary key in a database?
Primary key uniquely identifies each record in the table. Primary key consists of a single attribute or multiple
attributes in a combination.
The foreign key is the field in the child table that refers to a matching value in a column in another table
(parent). It cannot contain the values other than that column. It can contain the duplicate values also.
They both help in reducing data redundancy.
7. Briefly describe the two logical types of SQL.
The data stored on a database can be manipulated using some commands. There are two types of languages for
this task. These are:
i. Data definition language (DDL) includes database commands that define, modify and remove the structure
of various objects like tables, indexes, users, etc. in a database. Common DDL statements are CREATE, ALTER,
and DROP.
ii. Data manipulation language (DML) includes the commands that allows to access and manipulate data in a
database. E.g.,
Insertion of new information into the database - INSERT statement, deletion of information in the database
- DELETE statement and modification of information in the database - UPDATE statement.
8. List the steps to design a table using table wizard?
Following are the steps to create table using Table Wizard:
1. Table object > Select Use Wizard to Create Table in Tasks pane.
2. In the Table Wizard, select a sample table and add desired fields. Click Next button.
3. Specify desired field properties. Click Next button.
4. Specify for automatic primary key field or select a field to be a Primary key. You may uncheck the checkbox
to skip creating any primary key. Click Next button.
5. Specify a relevant, unique name to the table. Click Finish button.
9. How will you add a new field and a new constraint in a table? Explain with an example.
The syntax to add a field to a table is: Alter table “table name” add “new field” “type” before “existing field name”
For example, alter table item add item_type varchar(50).
The syntax to add a constraint on a field is: Alter table “table name” add [CONSTRAINT “constraint name”]
constraint definition.
For example, alter table item constraint “chk_qty” add check(qty > 0)

82
D.Answer the following questions – 5 marks each
1. Consider the following table and write SQL statements to answer the questions that follow:
SubscriberID Name Connection Pending_Amount
------------------------------------------------------------------------------------------------------------------------------
S0001 Anand Kumar Broadband 2200
S0002 Dinesh Verma Postpaid 3310
S0003 Minal Sen Postpaid 1200
S0004 Suman Kumari Broadband 0
S0005 Ravi Kumar Broadband 900
S0006 Atul Om Postpaid 0
i. Create table Billing with Subscriber ID as primary key, name should not be blank, default connection
is Prepaid.
Create table Billing(SubscriberID char(5) primary key, Name varchar(100) not null, Connection varchar(50)
default “Prepaid”, Pending_Amount currency)
ii. Display all the names starting with letter ‘A’.
Select Name from Billing where Name LIKE “A*”
iii. Display the connection type of those who have letter ‘u’ in their name anywhere.
Select Name, Connection from Billing where Name LIKE “*u*”
iv. Whose names are ending with letter ‘r’?
Select Name from Billing where Name LIKE “*r”
v. Display the interest on non-zero pending amounts as 8% along with total amount.
Select SubscriberID, Interest as Pending_Amount * .08, Total_Amount as Pending_Amount + (Pending_
Amount * .08) from Billing where Pending_Amount >0
vi. Display total pending amount connection type-wise.
Select Connection, SUM(Pending_Amount) from Billing group by Connection
vii. Increase non-zero pending amounts by 8%
Update Billing set Pending_Amount = Pending_Amount + (Pending_Amount * .08) where Pending_Amount >0
viii. Delete all records having non-zero pending amount.
Delete Billing where Pending_Amount >0
ix. Who is having no pending amount on broadband connection?
Select Names from Billing where Pending_Amount = 0 and Connection = ‘Broadband’
x. Insert a new record for subscriber code S0007 with suitable assumed values.
Insert into Billing Values(‘S0007’, ‘Amit Kumar Gupta’, ‘Broadband’, 0)
2. Perform following alterations in the above table:
i. Add a field Connection_Date
Alter table Billing add Connection_Date date
ii. Add a constraint on pending_amount to check if it is 0 or more.
Alter table Billing constraint chk_pa add check(pending_amount>=0)
iii. Rename the field ‘Name’ to Subscriber_Name.
Alter table Billing alter column “Name” rename to “Subscriber_Name”
iv. Rename the table to ‘Pending_Billings’.
alter table “Billing” rename to “Pending_Billings”

83

You might also like