0% found this document useful (0 votes)
67 views16 pages

IT Project RYTHAM

This project report summarizes information about a database project for a class on Information Technology. It includes an index listing 8 questions about databases and database management systems. The answers provide definitions and explanations of databases and their types, what a database management system is and examples, data types in databases, what object oriented databases are and categories of SQL commands, 10 SQL queries with examples and outputs, and database keys and their types. It also instructs the creation of a database table for a shopping application.

Uploaded by

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

IT Project RYTHAM

This project report summarizes information about a database project for a class on Information Technology. It includes an index listing 8 questions about databases and database management systems. The answers provide definitions and explanations of databases and their types, what a database management system is and examples, data types in databases, what object oriented databases are and categories of SQL commands, 10 SQL queries with examples and outputs, and database keys and their types. It also instructs the creation of a database table for a shopping application.

Uploaded by

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

Project Report

Session: 2020-21
Class-10
Subject: Information Technology (402)

Submitted by: Submitted to:


Name – RYTHAM JATWANI Ashraf Ali
Class:10-B
Roll No. 24
INDEX
1. What do you understand by Database? Explain their
types.
2. What is Database Management System? Give some
examples.
3. Explain the Data Types are available in DBMS.
4. What is OO Base? How it is useful?
5. What is SQL? What are the different categories of
commands available in SQL?
6. Write any 10 SQL Queries with their example and
output.
7. What do you understand by Database Keys? Explain
their types.
8. Create a Database ‘Shopping’ and create the table
according to the image given below:

ANSWERS

Question 1- what do you understand by database?


explain their types.
Ans.1 - A database is an organized collection of structured
information, or data, typically stored electronically in a computer
system. A database is usually controlled by a database management
system (DBMS). Together, the data and the DBMS, along with the
applications that are associated with them, are referred to as a
database system, often shortened to just database.
Data within the most common types of databases in operation today is
typically modeled in rows and columns in a series of tables to make
processing and data querying efficient. The data can then be easily
accessed, managed, modified, updated, controlled, and organized.
Most databases use structured query language (SQL) for writing and
querying data.

There are two tpes of databse


1)Flat file database - A flat file database is a database that stores data
in a plain text file. Each line of the text file holds one record, with
fields separated by delimiters, such as commas or tabs. While it uses a
simple structure, a flat file database cannot contain multiple tables
like a relational database can. Fortunately, most database programs
such as Microsoft Access and FileMaker Pro can import flat file
databases and use them in a larger relational database.

2)Relational database - A relational database is a type of database


that stores and provides access to data points that are related to one
another. Relational databases are based on the relational model, an
intuitive, straightforward way of representing data in tables. In a
relational database, each row in the table is a record with a unique ID
called the key. The columns of the table hold attributes of the data,
and each record usually has a value for each attribute, making it easy
to establish the relationships among data points.

Question 2 – What is database management system ?


Give some examples.
Ans.2 -Datbase mangement system(DBMS) is a databse
program.Technically speaking ,it is a software system that uses a
standard method of cataloging,retrieving, and running queries on data.
The DBMS manages incoming data,organizes it, and provides ways
for the data to be modified or extracted by users or other programs.

Some DBMS exaples include MySQL, PostgreSQL, Microsoft access


, SQL Server, filemaker, oracle, RDBMS, dBASE, Clipper , and
FoxPro.

Question 3 - Explain the data types are available in


DBMS.
Ans.3 -

Question 4 – What is OO Base ? What are the different


categories of commands available in SQL ?
Ans.4 – OO Base stands for OpenOffice Base it is a fully desktop
database management system, designed to meet the needs of a broad
array of users, from tracking a personal CD collctions , to produscing
a corporate monthly department sales reports.
The different categories of commands available in SQL are
• DATA DEFINATION LANGUAGE (DDL) COMMANDS
• DATA MANIPULTION LANGUAGE (DML) COMMAND
• TRANSACTION CONTROL LANGUAGE (TCL)
COMMANDS

Question 5 – what is sql ? What are different cateoris of


commands available in sql?
Ans. The Structured Query Language (SQL) is the most
popular query language used by major relational database
management systems such as MySQL, ORACLE, SQL Server,
etc.SQL is easy to learn as the statements comprise of
descriptive English words and are not case sensitive.
There are five types of SQL commands: DDL, DML, DCL, TCL, and DQL.

• Data Definition Language (DDL) DDL changes the


structure of the table like creating a table, deleting a table,
altering a table, etc. ...
• Data Manipulation Language. ...
• Data Control Language. ...
• Transaction Control Language. ...
• Data Query Language.

Question 6 – Write any 10 SQL queries with thier


examples and output .
Ans6. 1. Insert Query

We use Insert Command to insert records into a table. The SQL INSERT INTO
declaration is used to include new database rows in the database table.

Syntax:

INSERT INTO TABLE_NAME (column1, column2, column3,...columnN)] VALUES (value1,


value2, value3,...valueN);
Here, column1, column2,...columnN are the names of the columns in the table
into which you want to insert data.

If you add value for all columns of the table you may not have to specify the
column(s) name in the SQL query. Nonetheless, notice that the order of the
values is identical to that of the table columns. It will be the following SQL
INSERT INTO syntax:

Syntax:

INSERT INTO TABLE_NAME (Column1, Column2, .........., ColumnN) VALUES


(value1,value2,value3,...valueN);

Example:

As per the syntax of INSERT INTO syntax, we specify the name of the table
"INSERT INTO" keyword, followed the order of columns, in which you want the
values that need to be inserted. Post the "VALUES' keyword enter the column
values in order of the columns specified earlier.
1. INSERT INTO student (id, name, age) VALUES (‘1’, ‘Nitin’, ‘Noi
da’, 28);     
After firing this query, our table will look like:

ID Name Address Age

1 Nitin Noida 26

We can fire more such queries to fill records in our table:


1. Insert into student (id, name, address, age) values (‘2’, 'Ami
t', ‘New Delhi ‘23’);    
2. Insert into student (id, name, address, age) values (‘3’, 'Roh
it', ‘Bareilly’ ‘27’);    
So the table now becomes:

ID Name Address Age

1 Nitin Noida 26
2 Amit New Delhi 23

3 Rohit Bareily 27

2. Select Query
Viewing all records from a table. These results tables are called result-sets.

Syntax: The basic syntax of the SELECT statement is as follows:

SELECT column1, column2, columnN FROM table_name;

Here, column1, column2...are the fields of a table whose values you want to
fetch. If you want to fetch all the fields available in the field, then you can use the
following

Syntax:

SELECT * FROM table_name;

Example:
1. SELECT * FROM student;     
The result of this query will be a display of all rows present in the table.

ID Name Address Age

1 Nitin Noida 26

2 Amit New Delhi 23

3 Rohit Bareily 27

We may also use ORDER BY to organize the presented outcome in a similar


order in our chosen sentence. For example,
1. SELECT * FROM student ORDER BY age; 
Result is:
ID Name Address Age

1 Amit New Delhi 23

2 Nitin Noida 26

3 Rohit Bareily 27

The production is arranged in an increasing age sequence. When we choose to


structure the view in decreasing order we should use the DESC keyword after
the column name in the query.

3. Viewing only selected records from a table


When we do not want all records to fill our display screen, SQL offers the choice
to show only selected rows while there are a number of rows in a database.
Count is good for recording record numbers.

Syntax SELECT COUNT(1) FROM table_name;

Example:
1. SELECT COUNT(1) FROM student;  
The output of this query will be:

ID Name Address Age

1 Nitin Noida 26

If we fire:

The number of rows our table has shall be returned. In our query, we may even
use MAX & MIN. For eg, whether a student with a maximum age needs to be
provided with information, we can fire:

1. SELECT  id ,  name ,  MAX(age) FROM  student;  


We will get:

ID Name Address Age


3 Rohit Bareily 27

We can also check sum of a numeric column.

For example:
1. SELECT sum(age)FROM student;  
It will give 76 as output.

Remember, we can only use numerical columns for MAX, MIN, and SUM
functions. The text column utilizes certain features to trigger an error.

4. Deleting records from a table


To delete the selected rows from a table, just fire the following query,

Syntax:DELETE FROM student WHERE [condition];

Example:

1. DELETE  FROM student  WHERE name  = ‘Rohit’;   


This query will delete the entire row, or more than one row, from table ‘student’
where ‘name’ column has value ‘Rohit’.

In our case, the result of this query will look like the following table:

ID Name Address Age

1 Nitin Noida 26

2 Amit New Delhi 23

5. Changing data in existing records in a table


Syntax:The basic syntax of UPDATE query with WHERE clause is as follows:
UPDATE table_nameSET column1 = value1, column2 = value2...., columnN =
valueNWHERE [condition];

Assume that we want to alter a student's age in our table called 'Rohit.' The
following query will be used:

Example:

1. UPDATE  student SET  age =  28 WHERE  name =  ‘Rohit’;  


You may have found that while the values are characters, we define the term in
single quotes. That's an obligation.

Now if we fire:
1. SELECT * FROM student;  
We will get the following table as output:

ID Name Address Age

1 Nitin Noida 26

2 Amit New Delhi 23

3 Rohit Bareily 27

Please pay attention to UPDATE or DELETE queries using the WHERE clause.
Suppose there is more than one student called 'Rohit' in our 'class' list. The age
of all students called 'Rohit' is modified to 28 in this case. Therefore, the
PRIMARY KEY should always be included in the WHERE clause during the
modification or deletion.

We must always take note of the column data types when we modify the details.
A numeric column can only contain numbers while a text column can contain
text. This implies that if we use an UPDATE clause to place age = 'Rohit' in the
age list, SQL would make an exception. You can find out more about SQL's error
types and exceptions.
6. Viewing records from a table without knowing exact
details
In the real world, there is a strong risk of us not understanding precisely what
column values as we communicate with the database. For instance, because I
am a data operator in a firm, I might know that in our organization there is an
employee called Nitin as I might have heard other managers talking about
him. Now I want to see whole Nitin records but I don't know how he's spelling
his name. Is 'Nitin' OR 'Netin' If it is. In that case, we could use the SQL-supplied
'LIKE' operator.

We will fire the following query:

1. SELECT  * FROM  student WHERE  name LIKE  ‘n%n’; 


Output of this query will be:

ID Name Address Age

1 Nitin Noida 26

7. Using more than one condition in the WHERE clause


to retrieve records
Let us first introduce two more rows into our table to clarify the criteria for using
this parameter. Attempt to add two rows to our student table as ID 4 and 5,
called Shuchi and age twenty-two and twenty-four.

Our table now becomes:

Id Name Address Age

1 Nitin Noida 26

2 Amit New Delhi 23

3 Rohit Bareily 27

4 Shuchi Livknow 24
5 Shuchi Patna 24

Now if we fire our query as:


1. SELECT * FROM student WHERE name = ‘shuchi’;  
Then the output will be:

ID  Name Address Age

4 Shuchi Lucknow 22

5 Shuchi Patna 24

We have therefore noticed that we could not obtain a unique record simply by
using the name-value in the WHERE clause. Here, more than one condition must
be combined in WHERE that can simply be done with conditions such as AND or
OR. For example, if we fire:
1. SELECT * FROM student WHERE name = ‘shuchi’ AND age = 24;  
We get the following output:

ID Name Address Age

5 Shuchi Patna 24

To order to further enhance the quest, you may even merge AND & OR
requirements to the WHERE section. For example, if we fire
1. SELECT * FROM student WHERE name = ‘shuchi’ OR age > 23  
Output will be:

ID Name Address Age

1 Nitin Noida 26

3 Rohit Bareily 27

4 Shuchi Lucknow 22
5 Shuchi Patna 24

In a combination or individually in WHERE clause you can use different


conditions as AND, OR, <, > to get the required line.

8. Viewing only selected columns from a table


If we fire a query like:
1. SELECT name FROM student WHERE age > 25; 
The following output is displayed:

Name

Nitin

Rohit

We can notice that only student names are printed. Here we just have names of
those students whose age is over 25 because of the WHERE clause.

More than one column name may even be included with a comma in the SELECT
statement.

For example:

1. SELECT  name, address  FROM student;   


Gives this as output:

Name Address 

Nitin Noida 

Amit New Delhi 

Rohit Bareily

Shuchi Lucknow

Shuchi Patna
You can also change the sequence of columns to be displayed on your screen.

For example:

1. SELECT  age, name  FROM student; 


It will give the following output:

Age Name

26 Nitin

23 Amit

27 Rohit

22 Shuchi

24 Shuchi

9. Know the structure of the table


I also build a table in my database and overlook what all the columns are and
which column is the main column. You will know full information about the table
layout that you have generated with the aid of a simple question. Various SQL
servers provide various commands. For example, in SQLite3 the command is:

.schema student;

• Whereas in PostgreSQL it is \d student


• MySQL uses the following command: describe student;
• Where ‘student’ is our table’s name.

10. Checking the performance of the query


This is an advanced query. It’s particularly useful if you need to figure out why a
query is so slow.

Just fire the query:


1. EXPLAIN  QUERY PLAN  SELECT *  FROM student; 
This query gives the Query Cost of all operations.

EXPLAIN can be used to break the times of the different parts of your query
before a SQL statement. The explanation behind a sluggish query is good for
cataloging.

Question 7 – What do you understand by database


keys ? Explain their types.
Ans7. A key is data item that exclusively identifies a record.In other
words, key is a set of column(s) that is used to uniquely identify the
record in a table .Keys are also used to generate realtionship among
different databse tables or views.
Types of keys are
• PRIMARY KEY - A primary key ,is a key in a
relational databse that is unique for each record. It is a unique
identifier,such as a driver license numbe,telephone
number(incluing area code ). A realational database must always
have one and ink one primary key.
• FOREIGN KEY – A foreingn key used to link two tables
together . This is sometimes also calles as a referencing key. A
foreign key is a column or combination of columns whose
values match a primary key in a diferent table.
Question 8 – Create a Database ‘Shopping’ and
create the table

You might also like