0% found this document useful (0 votes)
76 views21 pages

Information Technology Part - B: Unit-3 Database Development I Define The Following

This document defines key database concepts like data, information, databases, DBMS, RDBMS, and database servers. It also describes database components like data items, fields, records, tables, queries, forms, and reports. It defines database concepts like primary keys, composite keys, foreign keys, and referential integrity. It discusses field properties, relationship types, applying criteria with wildcards, performing calculations, and grouping data. The goal is to organize data into a structured database for easy access, analysis and sharing of information.

Uploaded by

kakashi s
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)
76 views21 pages

Information Technology Part - B: Unit-3 Database Development I Define The Following

This document defines key database concepts like data, information, databases, DBMS, RDBMS, and database servers. It also describes database components like data items, fields, records, tables, queries, forms, and reports. It defines database concepts like primary keys, composite keys, foreign keys, and referential integrity. It discusses field properties, relationship types, applying criteria with wildcards, performing calculations, and grouping data. The goal is to organize data into a structured database for easy access, analysis and sharing of information.

Uploaded by

kakashi s
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/ 21

Information Technology

Part –B : Unit-3 Database Development

I Define the following:-

• Data - refers to all the single items that are stored in a database, Data is raw,
unorganized facts that need to be processed. Data can be something simple
and seemingly random and useless until it is organized.

Ex:- Each student's test score is one piece of data.

• Information - When data is processed, organized, structured or presented in a


given context so as to make it useful, it is called information.

Ex : The average score of a class or of the entire school is information that can
be derived from the given data.

• Database - A database is an organised collection of data. It helps us to enter,


manage, access and analyse a large amount of information quickly and
efficiently.

Advantages

• Ability to store large amounts of information


• Sharing information
• Eliminating duplications
• Information Security
• Reduced data redundancy
• Reduced updating errors and increased consistency
• Greater data integrity and independence from applications programs
• Improved data access to users through use of host and query languages
• Reduced data entry, storage, and retrieval costs

Features of Database

 Data Storage Management


 Data Transformation and Presentation
 Security Management
 Backup and Recovery Management
 Data Integrity Management
• DBMS -Database management system is a computerized record keeping
system that enables you to create, store, modify and extract information from
a database.

• RDBMS -RDBMS stands for Relational Database Management System.

An RDBMS is a DBMS software designed specifically for relational databases.


A relational database refers to a database that stores data in a structured
tabular format consisting of rows and columns. It also provides a facility to
define a primary key for unique identification of each table.

• Database Server
A database server is a server which uses a database application that
provides database services to other computer programs or to computers,
as defined by the client–server model.

• Data item-A database primarily contains information about a data item.

• Field –A field describes a particular attribute of a data item.

• A field is a column in the table.

• Another name for field is Attribute

• Record-A record is a set of information which is made of fields that belongs to


a data item.

• A record is a collection of related field values.

• Another name for record is Tuples.

• Table- A table is a collection of related data held in a table format within a


database. It consists of Fields (columns) and Records (rows).

• Queries-Queries help us to retrieve the filtered data from the database based
upon the conditions. They are also used to perform actions such as delete,
update etc on the data.
• Forms-Forms are the user friendly interfaces that facilitate the process of
entering data in tables and queries. A form accepts the data from the user and
forwards it to the corresponding table or query.

• Reports-Reports are used to display the selected data in a printable format.


They collect the summarised data from one or more tables or queries and
organise it in a printable form.

Primary Key-A primary key is a special relational database table column (or
combination of columns) designated to uniquely identify all table records.
A primary key’s main features are:

 It must contain a unique value for each row of data.


 It cannot contain null values.

• . For example, Student Table contains columns such as Rollno, Name, DOB ,
Address, Rollno can be considered as Primary Key

• Composite key (or) composite primary key - refers to cases where more than
one column is used to specify the primary key of a table.

• Foreign Key- A foreign key is a field or a column that is used to establish a link
between two tables. In simple words you can say that, a foreign key in one
table used to point primary key in another table.

• Referential integrity - Refers to the accuracy and consistency of data within a


relationship. In relationships, data is linked between two or more tables. ...
So, referential integrity requires that, whenever a foreign key value is used it
must reference a valid, existing primary key in the parent table.
Field properties

Decimal Specifies the number of decimal places to use when displaying numbers.
Places
Input Mask Displays editing characters to guide data entry. For example, an input mask might
display a dollar sign ($) at the beginning of the field.
Caption The label text that is displayed for this field by default in forms, reports, and
queries. If this property is empty, the name of the field is used. Any text string is
allowed.

An effective caption is usually brief.


Default Automatically assigns the specified value to this field when a new record is added.
Value
Validation Supplies an expression that must be true whenever you add or change the value
Rule in this field. Use in conjunction with the Validation Text property.
Required Requires that data be entered in the field.

Relationships:

 Relationships are the links that associate a field in one table with a field in
another table.
 A relationship works by matching a field with the same name in both the
tables.

There are 3 types of relationships in relational database design. They are:


 One-to-One

o A pair of tables bears a one-to-one relationship when a single record


in the first table is related to only one record in the second table, and
a single record in the second table is related to only one record in the
first table.
 One-to-Many (or Many-to-One)

o A one-to-many relationship exists between a pair of tables when a


single record in the first table can be related to one or more records in
the second table, but a single record in the second table can be related
to only one record in the first table.

 Many-to-Many
A pair of tables bears a many-to-many relationship when a single
record in the first table can be related to one or more records in the
second table and a single record in the second table can be related to
one or more records in the first table.

Criteria:
 Query criteria helps you to retrieve specific items from an
Access database.
 When you want to limit the results of a query based on the
values in a field, you use query criteria.

To Apply Crtiteria(based on MS Access)


Single criteria:
Criteria are specified in the criteria row of the design grid.
Specify the criteria value in the criteria row and the data will be
filtered accordingly in the query output.

Multiple criteria:
Specify the single criteria in the criteria row and for multiple
criteria type the second condition on the Or row of the same
column
Wild card character: Wildcards are special characters that can stand in for unknown
characters in a text value and are handy for locating multiple items with similar, but
not identical data. Wildcards can also help with getting data based on a specified
pattern match.

Character Description Example


* Matches any number of characters. You can wh* finds what, white, and
use the asterisk (*) anywhere in a character why, but not awhile or watch.
string.
? Matches a single alphabet in a specific b?ll finds ball, bell, and bill.
position.

[] Matches characters within the brackets. b[ae]ll finds ball and bell, but
not bill.
! Excludes characters inside the brackets. b[!ae]ll finds bill and bull, but
not ball or bell.

Like “[!a]*” finds all items


that do not begin with the letter
a.
- Matches a range of characters. Remember to b[a-c]d finds bad, bbd, and
specify the characters in ascending order (A to bcd.
Z, not Z to A).
# Matches any single numeric character. 1#3 finds 103, 113, and 123.
Performing calculations:

Create a calculated field in a table:

In Access, you can create a calculated field in a table. This eliminates the need for
a separate query to do calculations. For example, if you have a table that lists the
quantity, price and tax rate for each item in an order, you could add a calculated
field that shows the total price, like so:

[Quantity]*([UnitPrice]+([UnitPrice]*[TaxRate]))

The calculation cannot include fields from other tables or queries and the results of
the calculation are read-only.

Grouping of data :

The GROUP BY clause in Access combines records with identical values in the
specified field list into a single record. A summary value is created for each record
if you include an SQL aggregate function , such as Sum or Count, in the SELECT
statement.

Syntax:

SELECT fieldlist
FROM table
WHERE criteria
[GROUP BY groupfieldlist]

Information is often easier to understand when it is divided into groups. For


example, a report that groups sales by region can highlight trends that otherwise
might go unnoticed. In addition, placing totals (such as sums or averages) at the
end of each group in your report can replace a lot of manual interaction with a
calculator.

Access makes working with grouped reports easy. You can create a basic grouped
report by using the Report Wizard, you can add grouping and sorting to an existing
report, or you can revise grouping and sorting options that have already been
defined.
Forms:

Access is a database object that you can use to create a user interface for a database
application

Modifying Forms:

Layout view Layout view is the most intuitive view to use for form
modification, and it can be used for almost all the changes that you would want to
make to a form in Access.

In Layout view, the form is actually running. Therefore, you can see your data
much as it will appear when you are using the form. However, you can also change
the form design in this view. Because you can see the data while you are
modifying the form, this is a very useful view for setting the size of controls or
performing almost any other task that affects the appearance and usability of the
form.

If you encounter a task that cannot be performed in Layout view, you can switch to
Design view. In certain situations, Access displays a message that states that you
must switch to Design view before you can make a particular change.

Design view Design view gives you a more detailed view of the structure of your
form. You can see the Header, Detail, and Footer sections for the form. The form is
not actually running when it is shown in Design view. Therefore, you cannot see
the underlying data while you are making design changes. However, there are
certain tasks that you can perform more easily in Design view than in Layout view.
You can:

 Add a wider variety of controls to your form, such as bound object frames, page
breaks, and charts.
 Edit text box control sources in the text boxes themselves, without using the
property sheet.
 Resize form sections, such as the Form Header or the Detail section.
 Change certain form properties that cannot be changed in Layout view.
You use a form to manually update data. Data entry forms can provide an easier,
faster, and more accurate way to enter data. Forms can contain any number of
controls such as lists, text boxes, and buttons. In turn, each of the controls on the
form either reads data from or writes data to an underlying table field.

Find a record

You must first find a record before you can edit or delete it. In a form or datasheet
that contains only a small number of records, you can use the record navigation
buttons to navigate through the records until you find the one you want. When
there are many records, you can use the Find and Replace dialog box and filter for
the record.

Add a record to a table or form

1. Open the table form in Form View.


2. On the Home tab, in the Records group, click New, or click New (blank) record,
or press Ctrl+Plus Sign (+).
3. Find the record with an asterisk in the record selector, and enter your new
information.
4. Click or otherwise place the focus on the first field that you want to use, and then
enter your data.
5. To move to the next field in the same row, press TAB, use the Right or Left arrow
keys, or click the cell in the next field.

In a table, to move to the next cell in a column, use the Up or Down arrow keys, or
click the cell you want.

6. When you view another record or close the table or form, Access saves the new
record that you added.
Delete a record

1. Open the form in Form View.


2. Select the record or records that you want to delete.

To select a record, click the record selector next to the record, if the record selector
is available.

To extend or reduce the selection, drag the record selector (if it is available), or
press SHIFT+DOWN ARROW or SHIFT+UP ARROW.

3. Press DELETE, select Home > Records > Delete, or press Ctrl+Minus Sign (-).
II Answer in One Word

1. Which statement is used to retrieve records in a database?


A. Select

2. ___ represents a single, data item in a table.


A.Row or record

3. Which statement is used to modify the structure of database/table?


A. Alter

4. Which statement is deletes a database/table?


A.Drop

5. Which statement is used to renames the database/table?


A.Rename

6.Which statement removes all table records including allocated table spaces?

A.Truncate

III Answer the following

1. Write about various datatypes in MS Access.

A. A field’s data type determines what type of data to be entered into a field.
The various data types in Access 2010 are
• Numeric (or) Number (or)integer Types – This data type stores numeric
information for performing calculations.

Eg: Byte, integer

• Alphanumeric (or) short text (or) char (or) varchar Types –This data type is
used to store text or a combination of text and numbers.

• Binary Types –Binary data types contain byte strings

• Date/time (or) Date –This data type is used to store date/time-based data.

Eg:-Short Date, Short Time


2. Differentiate between char and varchar data types
A. The char is a fixed-length character data type. The varchar is a variable-length
character data type. Because char is a fixed-length data type, the remaining space
in the field is padded with blanks. Char takes up 1 byte per character.

*Varchar is a variable length string data type, so it holds only the characters
assigned to it.

3. Differentiate between Flat File and Relational Database.

A. Flat File:
In Flat file database
*data is stored in a single table.
*Usually suitable for less amount of data.
Eg:-Microsoft Excel

Relational Database:

In Relational Database
*Data is stored in multiple tables and the tables are linked using a common
field.
*Relational database is suitable for medium to large amount of data.
Eg:-Oracle, Microsoft Access
SQL COMMANDS

DDL DML DCL TCL


(Data Definition (Data Manipulation (Data Control (Transaction Control
Language) Language) Language) Language)

CREATE, ALTER, COMMIT,


SELECT, INSERT,
RENAME, DROP, GRANT, REVOKE ROLLBACK,
UPDATE, DELETE
TRUNCATE SAVEPOINT
4. What is DDL and DML? Give one example of each.
A. Data Definition Language (DDL)
A data definition language or data description language (DDL) is a
standard for commands that define the different structures in a database. DDL
statements create, modify and remove database objects such as tables, indexes,
and users.
Example CREATE, ALTER and DROP.
Data Manipulation Language (DML)
A data manipulation language (DML) is a language that enables users to
access and manipulate data in a database. The goal is to provide efficient human
interaction with the system.
For Example Insert, Update, Delete and Select

5. Explain about CREATE statement briefly with an example.

A. Create statement is used for creating a database or a table in any RDBMS


Software.

CREATE TABLE Table_Name([column definitions]) [table parameters]

• Column definitions: A comma-separated list consisting of any of the


following Column definition: [column name] [data type] {NULL | NOT NULL}
{column options}

• Primary key definition: PRIMARY KEY ([comma separated column list]) For
example, if you would like to create a table using the Create statement,
type the following and click Run.

CREATE TABLE Employee (ID INTEGER, Name VARCHAR (50), Department


VARCHAR (50), Address VARCHAR (120), Contact_Number INTEGER);

6. Explain briefly about DML commands.


A. Data manipulation Language involves:
 Retrieval of information from the database- SELECT statement
 Insertion of new information into the database - INSERT statement
 Modification of information in the database - UPDATE statement
 Deletion of information from the database - DELETE statement
SELECT statement

• A SELECT statement retrieves zero or more rows from one or more


database tables or database views. In most applications, SELECT is the most
commonly used Data Manipulation Language (DML) command.

• The SELECT statement has many optional clauses:

• WHERE specifies which rows to retrieve.

• ORDER BY specifies an order in which to return the rows.

• To retrieve all the columns in a table the syntax is:

SELECT * FROM <table_name>;

Ex: select * from SDetails;

INSERT statement

INSERT statement is used to add one or more records to a database.

• The general syntax of the insert statement is shown below.

INSERT INTO <table_name> (column_names) VALUES (values);

• To add a record in the database created earlier, type the following


statement and click on Run.

insert into SDetails (ID,Name,Rollno, DOB,Class,Phone,Email,Color,Location)


values (‘8’,’Roshan’,’23’,’2003-06-2020’,’X’,’
123456789’,’[email protected]’,’White’,’Hyderabad’);

Note :-

1. In Open office application it accepts data insertion using single


quotes ex: ‘123’
2. In MS office application it accepts data insertion using double quotes
ex: “123”
UPDATE statement

UPDATE statement is used for modifying records in a database.

• The general syntax of the update statement is as follows:

UPDATE <table_name> SET <column_name>= value WHERE <condition>;

• To update a record using update statement, type the following and


click on Run.

Update SDetails set Location = ‘Nacharam’ where Rollno = 14;

DELETE statement

• Delete Statement is used to remove one or more records in a database.

• The general syntax of the delete statement is as follows:

• DELETE FROM <table_name> WHERE <condition>;

• To delete one of the records in the table created earlier using delete
statement, type the following and click on Run:

• delete from SDetails where ID=8;

7. Write about DCL and TCL commands? Give examples.


• DCL(Data Control Language) :

• DCL includes commands such as GRANT and REVOKE which mainly


deals with the rights, permissions and security of the database
system.

Examples of DCL commands:

• GRANT-gives user’s access privileges to database.

• REVOKE-withdraw user’s access privileges given by using the


GRANT command.
• TCL(transaction Control Language) :

• TCL consists of those commands which control and manage the


changes that affect the data present in the database.
• COMMIT– commits a Transaction.

• ROLLBACK- rollbacks a transaction in case of any error occurs.

• SAVEPOINT–sets a savepoint within a transaction.


8. Write a Query To create a Table with the following structure

A. Create table Product


(PID Char(4),
Pname Varchar(20),
Description Varchar(40),
Price Decimal);
9. Consider the following Vendor table and write the queries

Table Vendor

(i) Write a Query to display all records


Ans Select * from vendor;
(ii) Write a Query to add a new row with the following details
(‘V005’, ‘Vadilal’, ‘2010-03-20’, ‘Pune’)
Ans Insert into Vendor values (‘V005’, ‘Vadilal’, ‘2010-03-20’, ‘Pune’);
(iii) Write a query to modify the location of V003 from Kolkata to Gujrat
Update Vendor Set location= ‘Gujrat’ Where location= ‘Kolkata’;
EMP
EID ENAME LOCATION D.O.A SALARY
6213 RUDRA HYDERABAD 14-02-2011 60,000
4226 MOHAN BANGALORE 22-05-2001 1,00,000
8172 KARAN DELHI 18-10-2019 30,000

1. Create table EMP with field names (eid, ename, location, doa)
2. Add one more column “Salalary” to EMP table
3. Apply a primary key to suitable field
4. Insert 6 records
5. View eid, ename from the table
6. View all the records and fields of the employee whose Salary is greater
than 55,000
7. Update the location to Hyderabad of the EMP whose Salary is less than
80,000
8. Delete the records of the emp whose Salary is greater than 1,00,000
9. Create another table transport with 5 fields
10. Delete transport table

To create table :

Syntax : create table <table_name> (field_name datatype(character limit-


only for character datatype) constraint);

Example : create table dps(sid number primary key, sname varchar(20), dob
date);

To alter table :

Syntax : alter table <table_name> add <field_name> datatype;

Example : alter dps add marks number;

To add primary key :


Syntax : alter table <table_name> add primary key(Field_name);

Example : alter table dps add primary key(sid);

To delete table :

Syntax : drop table <table_name>;

Example : drop table dps;

To delete all the records from the table :

Syntax : truncate table <table_name>;

Example : truncate table dps;

To insert data into the table :

Syntax : insert into <table_name>(field_names)


values(‘data1’,’data2’,’data3’………..);

Example : insert into dps(sid,sname,doa,marks) values(‘123’,’Suresh’,’12-


11-2015’,’65’);

Note :-

1. In Open office application it accepts data insertion using single


quotes ex: ‘abc’
2. In MS office application it accepts data insertion using double quotes
ex: “abc”
To view all the fields and records from the table :

Syntax : Select * from <table_name>;

Example : select * from dps;

To view selected fields from table :

Syntax : select <field_names> from <table_name>;

Example : select sname,marks from dps;


To view the fields based on condition :

Syntax : select * from <table_name> where <condition>;

select <field_names> from <table_name> where <condition>;

Example : select * from dps where marks>70;

Select * from dps where sid=154;

Select ename,doa,marks from dps where marks<35;

To sort the data in the table :

Syntax : select * from <table_name> order by <field_name>;

select <field_names> from <table_name> order by


<Field_name> ASC; (use ASC for arrange the data in ascending
order)

select <field_names> from <table_name> order by


<Field_name> DESC; (use DESC for arrange the data in
descending order)

Example : select * from dps order by sid;

Select * from dps order by marks DESC;

Select ename,doa,marks from dps order by marks;

To update the data in the table :

Syntax : update <table_name> set <field_name>=”value” where


<condition>;

Example : update dps set marks=66 where sid=123;

To delete the record from the table :

Syntax : delete from <table_name> where <condition>;

Example : delete from dps where sname=”mohan”;

You might also like