Sie sind auf Seite 1von 14

Q1) What is DBMS and What are its functions ?

A database management system is a set of software programs that allows users to create, edit and update data in database files, and store and retrieve data from those database files. Data in a database can be added, deleted, changed, sorted or searched all using a DBMS. If you were an employee in a large organization, the information about you would likely be stored in different files that are linked together. One file about you would pertain to your skills and abilities, another file to your income tax status, another to your home and office address and telephone number, and another to your annual performance ratings. By cross-referencing these files, someone could change a person's address in one file and it would automatically be reflected in all the other files. DBMSs are commonly used to manage: Membership and subscription mailing lists Accounting and bookkeeping information The data obtained from scientific research Customer information Inventory information Personal records Library information There are several functions that a DBMS performs to ensure data integrity and consistency of data in the database. The ten functions in the DBMS are: Data dictionary management Data storage management Data transformation and presentation Security management Multiuser access control Backup and recovery management Data integrity management Database access languages and application programming interfaces Database communication interfaces Transaction management.
0902ME111039

Nitin Mukesh

Q2) Draw the ER relationship diagram of College Management. Phone no. PRINCIPAL Name

controls

controls

controls

controls

ME

library

Admin.& accounts

IT

Headed by

Headed by

Headed by

Headed by

Faculty

Librarian

Adm.

!!icer

Faculty

Id

Name

Id

Name

Id

Name

Id

Name

Teaches

"oo#s

Payment &!ees

Teaches

$tudentME $name $Id


Nitin Mukesh

$tudentIT $name $Id


0902ME111039

Q3)What is Normalization and what are its types?


Normalization is systematic approach of decomposing tables to eliminates data redudancy.Normalization is the process of organizing data into a related table; it also eliminates redundancy and increases the integrity which improves performance of the query. To normalize a database, we divide the database into tables and establish relationships between the tables. Database normalization can essentially be defined as the practice of optimizing table structures. Optimization is accomplished as a result of a thorough investigation of the various pieces of data that will be stored within the database, in particular concentrating upon how this data is interrelated. Normalization Avoids: Duplication of Data - The same data is listed in multiple lines of the database Insert Anomaly - A record about an entity cannot be inserted into the table without first inserting information about another entity - Cannot enter a customer without a sales order Delete Anomaly - A record cannot be deleted without deleting a record about a related entity. Cannot delete a sales order without deleting all of the customer's information. Update Anomaly - Cannot update information without changing information in many places. To update customer information, it must be updated for each sales order the customer has placed

TYPES-:

1) 1st Normal Form 2) 2nd Normal Form 3) 3rd Normal Form 4) 4th Normal Form 5) 5th Normal form 6) Boyce Codd Normal Form

Nitin Mukesh

0902ME111039

Q6)What is SQL and What are its types? SQL stands for Structured Query Language. SQL language is used to create, transform and retrieve information from RDBMS (Relational Database Management Systems. SQL is a declarative programming language designed for creating and querying relational database management systems. SQL is relatively simple language, but its also very powerful. SQL can insert data into database tables. SQL can modify data in existing database tables. SQL can delete data from SQL database tables. Finally SQL can modify the database structure itself create/modify/delete tables and other database objects. Types of SQL statements-: Data Definition Language (DDL) Statements: Data definition language (DDL) statements let you to perform these tasks: Create, alter, and drop schema objects Grant and revoke privileges and roles Analyze information on a table, index, or cluster Establish auditing options Add comments to the data dictionary Data Manipulation Language (DML) Statements Data manipulation language (DML) statements access and manipulate data in existing schema objects. These statements do not implicitly commit the current transaction. The data manipulation language statements are: CALL DELETE EXPLAIN PLAN INSERT MERGE SELECT UPDATE
Nitin Mukesh 0902ME111039

The SELECT statement is a limited form of DML statement in that it can only access data in the database. It cannot manipulate data in the database, although it can operate on the accessed data before returning the results of the query. Q7)Transaction Control Statements: Transaction control statements manage changes made by DML statements. The transaction control statements are: COMMIT ROLLBACK SAVEPOINT SET TRANSACTION All transaction control statements, except certain forms of the COMMIT and ROLLBACK commands, are supported in PL/SQL. For information on the restrictions, see COMMIT and ROLLBACK Session Control Statements: Session control statements dynamically manage the properties of a user session. These statements do not implicitly commit the current transaction. PL/SQL does not support session control statements. The session control statements are: ALTER SESSION SET ROLE System Control Statement: The single system control statement, ALTER SYSTEM, dynamically manages the properties of an Oracle Database instance. This statement does not implicitly commit the current transaction and is not supported in PL/SQL.

Embedded SQL Statements: Embedded SQL statements place DDL, DML, and transaction control statements within a procedural language program. Embedded SQL is supported by the Oracle precompilers.

Nitin Mukesh

0902ME111039

Q7)To study the various types of JOINs. 1. JOIN or INNER JOIN : In this kind of a JOIN, we get all records that match the condition in both the tables, and records in both the tables that do not match are not reported. In other words, INNER JOIN is based on the single fact that : ONLY the matching entries in BOTH the tables SHOULD be listed. Note that a JOIN without any other JOIN keywords (like INNER, OUTER, LEFT, etc) is an INNER JOIN. In other words, INNER JOIN is a Syntactic sugar for JOIN 2. OUTER JOIN : Outer Join retrieves Either, the matched rows from one table and all rows in the other table Or, all rows in all tables (it doesn't matter whether or not there is a match). There are three kinds of Outer Join : 2.1 LEFT OUTER JOIN or LEFT JOIN This join returns all the rows from the left table in conjunction with the matching rows from the right table. If there are no columns matching in the right table, it returns NULL values. 2.2 RIGHT OUTER JOIN or RIGHT JOIN This join returns all the rows from the right table in conjunction with the matching rows from the left table. If there are no columns matching in the left table, it returns NULL values. 2.3 FULL OUTER JOIN or FULL JOIN This join combines left outer join and right outer join. It returns row from either table when the conditions are met and returns null value when there is no match. In other words, OUTER JOIN is based on the fact that : ONLY the matching entries in ONE OF the tables (RIGHT or LEFT) or BOTH of the tables(FULL) SHOULD be listed. Note that OUTER JOIN is a loosened form of INNER JOIN. 3. NATURAL JOIN : It is based on the two conditions : 1. the JOIN is made on all the columns with the same name for equality.
Nitin Mukesh 0902ME111039

2. Removes duplicate columns from the result.

This seems to be more of theoretical in nature and as a result (probably) most DBMS don't even bother supporting this. 4. CROSS JOIN : It is the Cartesian product of the two tables involved. The result of a CROSS JOIN will not make sense in most of the situations. Moreover, we wont need this at all (or needs the least, to be precise). 5. SELF JOIN : It is not a different form of JOIN, rather it is a JOIN (INNER, OUTER, etc) of a table to itself.

Nitin Mukesh

0902ME111039

Q8)To study the various types of Integrity Constraints. Before one can start to implement the database tables, one must define the integrity constraints. Intergrity means something like 'be right' and consistent. The data in a database must be right and in good condition. There are the domain integrity, the entity integrity, the referential integrity and the foreign key integrity constraints. Domain Integrity Constraint Domain integrity means the definition of a valid set of values for an attribute. You define - data type, - lenght or size - is null value allowed - is the value unique or not for an attribute. You may also define the default value, the range (values in between) and/or specific values for the attribute. Some DBMS allow you to define the output format and/or input mask for the attribute. These definitions ensure that a specific attribute will have a right and proper value in the database. Entity Integrity Constraint The entity integrity constraint states that primary keys can't be null. There must be a proper value in the primary key field. This is because the primary key value is used to identify individual rows in a table. If there were null values for primary keys, it would mean that we could not indentify those rows. On the other hand, there can be null values other than primary key fields. Null value means that one doesn't know the value for that field. Null value is different from zero value or space. In the Car Rental database in the Car table each car must have a proper and unique Reg_No. There might be a car whose rate is unknown - maybe the car is broken or it is brand new - i.e. the Rate field has a null value. See the picture below.
Nitin Mukesh 0902ME111039

The entity integrity constraints assure that a spesific row in a table can be identified.

Referential Integrity Constraint The referential integrity constraint is specified between two tables and it is used to maintain the consistency among rows between the two tables. The rules are: 1. You can't delete a record from a primary table if matching records exist in a related table. 2. You can't change a primary key value in the primary table if that record has related records. 3. You can't enter a value in the foreign key field of the related table that doesn't exist in the primary key of the primary table. 4. However, you can enter a Null value in the foreign key, specifying that the records are unrelated. Examples Rule 1. You can't delete any of the rows in the CarType table that are visible in the picture since all the car types are in use in the Car table. Rule 2. You can't change any of the model_ids in the CarType table since all the car types are in use in the Car table. Rule 3. The values that you can enter in the model_id field in the Car table must be in the model_id field in the CarType table. Rule 4. The model_id field in the Car table can have a null value which means that the car type of that car in not known Foreign Key Integrity Constraint There are two foreign key integrity constraints: cascade update related fields and cascade delete related rows. These constraints affect the referential integrity constraint.

Nitin Mukesh

0902ME111039

Cascade Update Related Fields Any time you change the primary key of a row in the primary table, the foreign key values are updated in the matching rows in the related table. This constraint overrules rule 2 in the referential integrity constraints. If this contraint is defined in the relationship between the tables Car and CarType, it is possible to change the model_id in the CarType table. If one should change the model_id 1 (Ford Focus) to model_id 100 in the CarType table, the model_ids in the Car table would change from 1 to 100 (cars ABC112, ABC-122, ABC-123).

Nitin Mukesh

0902ME111039

Q9)To study the various types of SET operator. Union-: UNION is used to combine the results of two or more Select statements. However it will eliminate duplicate rows from its result set. In case of union, number of columns and data type must be same in both the tables. Example of UNION The *First* table, ID Name 1 abhi 2 adam The *Second* table, ID Name 2 adam 3 Chester Union SQL query will be, select * from First *UNION* select * from second The result table will look like, ID NAME 1 abhi 2 adam 3 Chester Intersect-: Intersect operation is used to combine two SELECT statements, but It only retuns the records which are common from both SELECT statements. In case of *Intersect* the number of columns and datatype must be same. MySQL does not support INTERSECT operator. Example of Intersect The *First* table, ID NAME 1 abhi 2 adam The *Second* table, ID NAME 2 adam 3 Chester
Nitin Mukesh 0902ME111039

Intersect query will be, select * from First *INTERSECT* select * from second The result table will look like ID NAME 2 adam Minus-: Minus operation combines result of two Select statements and return only those result which belongs to first set of result. MySQL does not support INTERSECT operator. Example of Minus The *First* table, ID NAME 1 abhi 2 adam The *Second* table, ID NAME 2 adam 3 Chester Minus query will be, select * from First *MINUS* select * from second The result table will look like, ID NAME 1 abhi

Nitin Mukesh

0902ME111039

Q10)To study of group functions. Group functions are built-in SQL functions that operate on groups of rows and return one value for the entire group. These functions are: COUNT, MAX, MIN, AVG, SUM, DISTINCT. COUNT (): This function returns the number of rows in the table that satisfies the condition specified in the WHERE condition. If the WHERE condition is not specified, then the query returns the total number of rows in the table. For Example: If you want the number of employees in a particular department, the query would be: SELECT COUNT (*) FROM employee WHERE dept = 'Electronics'; The output would be '2' rows. If you want the total number of employees in all the department, the query would take the form: SELECT COUNT (*) FROM employee; The output would be '5' rows. DISTINCT(): This function is used to select the distinct rows. For Example: If you want to select all distinct department names from employee table, the query would be: SELECT DISTINCT dept FROM employee; To get the count of employees with unique name, the query would be: SELECT COUNT (DISTINCT name) FROM employee; MAX(): This function is used to get the maximum value from a column. To get the maximum salary drawn by an employee, the query would be: SELECT MAX (salary) FROM employee; MIN(): This function is used to get the minimum value from a column. To get the minimum salary drawn by an employee, he query would be: SELECT MIN (salary) FROM employee; AVG(): This function is used to get the average value of a numeric column. To get the average salary, the query would be SELECT AVG (salary) FROM employee;
Nitin Mukesh 0902ME111039

SUM(): This function is used to get the sum of a numeric column To get the total salary given out to the employees, SELECT SUM (salary) FROM employee;

Nitin Mukesh

0902ME111039