dms assignment

22
DMS Assignment A Q1. What are the disadvantages of flat-file system? Answer: Flat File Databases: Data stored on an ICT system is stored and organised in files. When the data is organised in rows and columns with data values being repeated, it is called a flat file. A flat file looks like a spreadsheet; it is two dimensional and has no related files (or tables). Flat files are easy to create and use (for small amounts of data). Data is often repeated in a flat file and therefore they can be quite large in size. In the example above, each subject that the pupil studies has to be entered as a separate record. Redundancy: this file has a very simple row and column structure. There are no relationships between data. The main weakness of this type of file is that data has to be repeated. Data Integrity: The more often data has been recorded the higher the possibility of the data having an error or inconsistency. The user of the data must be able to rely on the correctness and accuracy of the data. The correctness, reliability and accuracy of the data is called data integrity. Disadvantages of flat file databases: The computer has more data to read through, so accessing and searching through them can be slow. Data has to be repeated and leads to inputting errors and inconsistencies File sizes can be large due to repeated data Q2. What are different database constraints? Answer: Primary Key Constraint / Foreign Key Constraints / Check Constraints. An RDBMS enables data sharing between users. At the same time, you can ensure consistency of data across multiple tables by using integrity constraints. An RDBMS uses various types of data integrity constraints. These types include entity, column, referential and user-defined constraints.

Upload: tanuj-ghimire

Post on 24-Oct-2015

416 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: DMS Assignment

DMS Assignment A

Q1. What are the disadvantages of flat-file system?

Answer: Flat File Databases: Data stored on an ICT system is stored and organised in files. When the data is organised in rows and columns with data values being repeated, it is called a flat file.

A flat file looks like a spreadsheet; it is two dimensional and has no related files (or tables). Flat files are easy to create and use (for small amounts of data). Data is often repeated in a flat file and therefore they can be quite large in size.

In the example above, each subject that the pupil studies has to be entered as a separate record.

Redundancy: this file has a very simple row and column structure. There are no relationships between data. The main weakness of this type of file is that data has to be repeated. Data Integrity: The more often data has been recorded the higher the possibility of the data having an error or inconsistency. The user of the data must be able to rely on the correctness and accuracy of the data. The correctness, reliability and accuracy of the data is called data integrity.

Disadvantages of flat file databases:

The computer has more data to read through, so accessing and searching through them can be slow.

Data has to be repeated and leads to inputting errors and inconsistencies File sizes can be large due to repeated data

Q2. What are different database constraints?Answer: Primary Key Constraint / Foreign Key Constraints / Check Constraints.An RDBMS enables data sharing between users. At the same time, you can ensure consistency of data across multiple tables by using integrity constraints. An RDBMS uses various types of data integrity constraints. These types include entity, column, referential and user-defined constraints.The constraint, entity, ensures uniqueness of rows, and the constraint column ensures consistency of the type of data within a column. The other type, referential, ensures validity of foreign keys, and user-defined constraints are used to enforce specific business rules.An RDBMS minimizes the redundancy of data.

NOT NULL constraints : NOT NULL constraints prevent null values from being entered into a column.

Unique constraints : Unique constraints ensure that the values in a set of columns are unique and not null for all rows in the table. The columns specified in a unique constraint must be defined as

Page 2: DMS Assignment

NOT NULL. The database manager uses a unique index to enforce the uniqueness of the key during changes to the columns of the unique constraint.

Primary key constraints: You can use primary key and foreign key constraints to define relationships between tables.

(Table) Check constraints : A check constraint (also referred to as a table checkconstraint) is a database rule that specifies the values allowed in one or more columns of every row of a table. Specifying check constraints is done through a restricted form of a search condition.

Foreign key (referential) constraints : Foreign key constraints (also known as referential constraints or referential integrity constraints) enable you to define required relationships between and within tables.

Informational constraints : An informational constraint is a constraint attribute that can be used by the SQL compiler to improve the access to data.  Informational constraints are not enforced by the database manager, and are not used for additional verification of data; rather, they are used to improve query performance.

Q3. What is the difference between internal & external schema?Ans. Three-schema Architecture Reminder:  A schema is a description of the structure of the databaseInternal level has an internal schemaConceptual level has a conceptual schemaExternal level usually has several external schemasNote that each of these schemas are only descriptions of data; the data really only exists at the physical level External LevelThe end user is presented with special views that are tailored to their specific needsSome of these views may be forms to fill out, others for interactive retrieval of information, etc.Many different views may be available that are completely different that the way the base tables are arrangedConceptual or logical levelDescription of the structure of the entire DBHides the details of physical storageConcentrates on describing entities, data types, relationships, user operations, and constraints.In the relational model, this is the base tablesChanges at this level can be made without having any effect on the external level

 Internal LevelThis is a description of the physical storage structure of the databaseOperations performed here are translated into modifications of the contents and structure of the files

Q4. What are the characteristics of data in the database?Ans. Characteristics of the data in the Database Management System

1. Sharing of the data takes place amongst the different type of the users and applications.2. Data exists permanently.3. Data must be very much correct in the nature and should also be in accordance with the real world entity that they represent.4. Data can live beyond the scope of the process that has created it.5. Data is not at all repeated.6. Changes that are made in the schema at one level should not at all affect the other levels.

Advantages of the Database Management System 1. Helps in reducing the complex nature of the systems environment due to the central

Page 3: DMS Assignment

control or the management of the data, access, utilization and the security.2. Reduces the data redundancy and also the inconsistency as the same data elements are not at all repeated.3. Also promotes the integrity of the data throughout the system or an organization.4. Provides for the central control of the data creation and also for the definition.5. Reduces or completely finishes the confusion that creeps in to the data.6. Reduces the costs relating the program development and the maintenance.7. Separates the logical view and the physical arrangement.8. Reduces the program data dependence.9. Permits the ad hoc queries.10. Provides flexibility in the information systems.11. Increases access and availability of the information.

Q5. What are the views ? How are they useful?

A database view displays one or more database records on the same page. A view can display some or all of the database fields. Views have filters to determine which records they show. Views can be sorted to control the record order and grouped to display records in related sets. Views have other options such as totals and subtotals.

Most users interact with the database using the database views. A key to creating a useful database is a well-chosen set of views. Luckily, while views are powerful, they are also easy to create.

Let's start by looking at an example view called Location from a Training Schedule database. This view shows the 2003 training schedule, sorted by the cities where the classes were held:

All the views available for a database appear in the view selector (the View by list). You can customize all aspects of a view, including:

The name of the view The fields that appear in the view

Page 4: DMS Assignment

The column title for each field in the view The order of the fields in the view The width of columns in the view, as well as the overall width of the view The set of records that appear in the view (Filtering) The order in which records are displayed in the view (Sorting & Grouping) Column totals for numeric and currency fields (Totaling & Subtotaling)

In addition to seeing the view on screen, users can also print out the view on paper. They can do this using the built-in print button or by using a defined report, which allows you to customize details of the print out.

Views are basically a join of two or more underlying database tables. Certain tables are logically related and make sense and more meaning when viewed linked together. Instead os making these joins at runtime and increasing overheads, views when existing can provide information readily such as in Search Helps in data entry screens. 

Another example is when there is a table with many fields and it does not make a lot of sense to see all of them together everytime, it is better we project only certain columns that we want to see.  There are four types of views:a) Database View (Generally used a a read only view)b) Maintenance View (Used as a means to maintain the underlying tables participating in the view)c) Projection View (Single table view)d) Help View (used in 'search helps' got by pressing F4)

Q6. What is the difference between Union & Set Intersection Operation?

Ans: The UNION, EXCEPT, and INTERSECT operators all operate on multiple result sets to return a single result set:

The UNION operator combines the output of two query expressions into a single result set. Query expressions are executed independently, and their output is combined into a single result table.

The EXCEPT operator evaluates the output of two query expressions and returns the difference between the results. The result set contains all rows returned from the first query expression except those rows that are also returned from the second query expression.

The INTERSECT operator evaluates the output of two query expressions and returns only the rows common to each.

The following figure illustrates these concepts with Venn diagrams, in which the shaded portion indicates the result set.

Figure: Result Set

Syntax

The following syntax diagram shows how to construct a UNION expression.

UNION expression:

Page 5: DMS Assignment

.-(-.|--+---+--query_expression-------------------------------------->

.-------------------------------------------------. V .-(-. | .-)-.>----+-UNION-----+--+-----+--+---+--query_expression-+--+---+---| +-EXCEPT----+ '-ALL-' '-INTERSECT-'

query_expression

Specifies any valid join or nonjoin query expression, as defined on page Syntax.

Each query expression in the statement must have the same number of columns in its select list. These corresponding columns must be listed in the same order, but they do not have to have the same names. The names of the columns in the result table are taken from the first query expression; parentheses do not change this rule.

To define a different column heading for the result table, use the AS clause in the select list of the first query expression; alternatively, if union_expressionoccurs in the FROM clause, provide headings by using a correlation name and a column list (see page Table references).

Corresponding columns in each query expression must be of the same data type, or there must be a valid implicit conversion between the data types. Smaller data types are converted to larger data types, and less precise data types are converted to more precise data types. For example, if a column is of data type REAL and the corresponding column is of data type FLOAT, the column in the result table is FLOAT because FLOAT is more precise than REAL.

The data type conversion results table on page Data type conversions defines conversions between data types of corresponding columns.

UNION, EXCEPT, INTERSECT

UNION combines the rows from two or more result sets into a single result set.

EXCEPT evaluates two result sets and returns all rows from the first set that are not also contained in the second set.

INTERSECT computes a result set that contains the common rows from two result sets.

UNION, INTERSECT, and EXCEPT operators can be combined in a single UNION expression.

In statements that include multiple operators, the default order of evaluation (precedence) for these operators is left to right; however, the INTERSECT operator is evaluated before UNION and EXCEPT. The order of evaluation can be modified with parentheses.

ALL

If ALL is specified, duplicate rows returned by union_expression are retained. If two query expressions return the same row, two copies of the row are returned in the final result. If ALL is not specified, duplicate rows are eliminated from the result set.

In statements with multiple UNION, EXCEPT, and INTERSECT operators in which the ALL keyword is used, the order of evaluation can affect the results. The placement of the ALL keyword in relation to the query evaluation determines the duplicates that are retained and eliminated. If the last operation performed does not contain the ALL keyword, any duplicates retained from previous evaluations are eliminated.

Usage notes

Page 6: DMS Assignment

The UNION and EXCEPT operators have the same precedence. A query with multiple operators is evaluated from left to right. The following example:

query_expression1 union query_expression2 except query_expression3

is evaluated as:

(query_expression1 union query_expression2) except query_expression3

The INTERSECT operator has higher precedence than the UNION and EXCEPT operators. Therefore, in the absence of parentheses, INTERSECT operations are always evaluated first. The example:

query_expression1 union query_expression2 intersect query_expression3

is evaluated as:

query_expression1 union (query_expression2 intersect query_expression3)

Parentheses that override the default precedence affect processing order and therefore which duplicate rows are retained and eliminated.

Joins specified in union_expression take higher precedence than all three operators unless the default order is changed with parentheses.

An INSERT INTO...SELECT statement can contain UNION, INTERSECT, and EXCEPT operators:

insert into orders.all select * from orders.new union select * from orders.old

When queries use search conditions that contain OR connectives, you can sometimes improve performance by rewriting those queries with UNION operators. 

DMS Assignment B

Q1. Explain the DBMS architecture in detail.

Page 7: DMS Assignment

Ans:Data ModelingA data model is used to describe the structure "logic" and "physics" of a database. Relationships, data types and constraints are known as the structure or level, dividing into 2 types:

o High Level - we call conceptual data model or Entity-Relationship model, its main concept is a projection of the data that gets closest to the vision that the user has data.

o Low - known as physical data model, is what provides a detailed view yet of how the data are aramazenados computer.

SchemesWhen using the term "description" of the database, as we understand the call of "schema of a database" that is specified for a project database.

InstancesInstances are formed when a data is saved in the database for a certain time they formed these database instances, being changed every time a change in the database is performed. DBMS ensures that all instances satisfying the schema of the database, respecting its structure and its constraints.

In a DBMS architecture has as main objective, separate user applications of physical data that are divided from the diagrams below:

o Level domestic or internal schema - uses a data model that shows the physical storage structure of the database, the details of the saved data and access paths.

o Level conceptual or conceptual scheme - performs a full description of the structure of the database but did not offer details of the data stored in the database.

o Level or external layout view - describes the views of the database to a group of users that shows which users have access to this database.

Figure 1: Architecture of a DBMS Layers

Data IndependenceWe can say that is allowed to perform schema changes or level of a database without changing a higher level. Recalling that only those levels or regimens are shown in Figure 1. Below is representing two types of data independence:

Page 8: DMS Assignment

o Logical data independence: change only the conceptual level, without any change in the external or in user applications.

o Physical Data Independence: change the internally without having to change the conceptual level, externally or user applications

Languages for Data ManipulationThe use of language DDL (Data Definition Language - Data Definition Language) is defined by the conceptual and internal level. When there is a separation of internal and conceptual that is not absorbed a clear view of the user, the DBMS has to compile the DDL action, with the action, permission to execute the statements identified by their descriptions of schemes / levels where you will store them in the DBMS catalog.Where this detachment has an understanding of the user uses the language SDL (Storage Definition Language - Storage Definition Language) for specifying schema / internally.By the end, when the DBMS uses the architecture with three levels, the language used is VDL (Vision Definition Language) that serves to deinição of views (views) of the databaseWhen the developer has knowledge in language SQL (Strucuture Query Language) simply just use the basic commands that form the language DDL, DML and DCL, which are described below:

o DDL (commands that create objects) - CREATE TABLE, CREATE VIEW, CREATE INDEX, CREATE PROCEDURE among thers.

o DCL (commands that help in the security of the database) - GRANT, REVOKE.o DML (commands responsible for altering the data) - SELECT, DELETE, UPDATE, INSERT.

Classification of DBMSo Users: single user, are used in workstations, minicomputers and large machines.o Location: have 2 states located and distributed. When all data is located are on a single disk, if

the data is distributed across multiple machines.o Environment: it has two types, the homogeneous environment that is formed by a single DBMS

and heterogeneous environment that is composed of different DBMSs. One example is to have a system running two types of database.

Figure 2: Structure of a System Manager Database

Q2. What is ER model? Draw ER diagram for a Hospital Management System.

Page 9: DMS Assignment

Ans. ER Model is a high-level data model that is useful in developing a conceptual design for a database. An ER model is a diagram containing entities or "items", relationships among them, and attributes of the entities and the relationships.In software engineering, an entity–relationship model (ER model for short) is an abstract and conceptual representation of data. Entity–relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database, and its requirements in a top-down fashion. Diagrams created by this process are called entity–relationship diagrams or ER diagrams.

The building blocks: entities, relationships, and attributes

Two related entities An entity with an attribute A relationship with an attribute

ER diagram for a Hospital Management System

Q3. What is normalization? Explain different types of normal forms.

Page 10: DMS Assignment

There are many different ways of designing good database. One of such methodologies is the method involving ‘Normalization’. Normalization theory is built around the concept of normal forms. Normalization reduces redundancy. Redundancy is unnecessary repetition of data. It can cause problems with storage and retrieval of data. During the process of normalization, dependencies can be identified, which can cause problems during deletion and updation. Normalization theory is based on the fundamental notion of Dependency. Normalization helps in simplifying the structure of schema and tables.

There are 5 different types of normal forms.1. First Normal Form: A relation is in 1st Normal form (1NF) if and only if, in every legal value of that relation, every tuple contains exactly one value for each attribute. 1NF relations have a number of discrepancies and therefore it not the most desirable form of a relation.Let us take a relation (modified to illustrate the point in discussion) as Rel1 {S#, SUPPLYSTATUS, SUPPLYCITY, P#, PARTQTY}

Primary Key{S#, P#}

FD {SUPPLYCITY → SUPPLYSTATUS}

2. Second Normal FormA relation is in 2NF if and only if it is in 1NF and every nonkey attribute is fully functionallydependent on the primary key. Here it has been assumed that there is only one candidate key,which is of course primary key.A relation in 1NF can always decomposed into an equivalent set of 2NF relations. The reductionprocess consists of replacing the 1NF relation by suitable projections.

We have seen the problems arising due to the less-normalization (1NF) of the relation. The

remedy is to break the relation into two simpler relations.

REL2{S#, SUPPLYSTATUS, SUPPLYCITY} and

REL3{S#, P#, PARTQTY}

REL2 and REL3 are in 2NF with their {S#} and {S#, P#} respectively. This is because all

nonkeys of REL1{ SUPPLYSTATUS, SUPPLYCITY}, each is functionally dependent on the

primary key that is S#. By similar argument, REL3 is also in 2NF. Evidently, these two relations have overcome all the update anomalies stated earlier. Now it is possible to insert the facts regarding supplier S5 even when he is not supplied any part, which was earlier not possible. This solves insert problem. Similarly, delete and update problems are also over now.INSERT: We are unable to insert the fact that a particular city has a particular status until wehave some supplier actually located in that city.DELETE: If we delete sole REL2 tuple for a particular city, we delete the information that thatcity has that particular status.UPDATE: The status for a given city still has redundancy. This causes usual redundancyproblem related to update.

3. Third Normal Form A relation is in 3NF if only if it is in 2NF and every non-key attribute is non-transitively

dependent on the primary key.

To convert the 2NF relation into 3NF, once again, the REL2 is split into two simpler relations – REL4 and REL5 as shown below.

Page 11: DMS Assignment

RELATION 4 {S#, SUPPLYCITY} and

RELATION 5

{SUPPLYCITY SUPLLYSTATUS} Sample relation is shown below.

RELATION 4 RELATION 5 S# SUPPLYCITY SUPPLYCITY SUPPLYSTATUS

S1 Madras Madras 200

S2 Mumbai Mumbai 100

S3 Mumbai Kolakata 300

S4 Madras S5 Kolkata

Evidently, the above relations RELATION 4 and RELATION5 are in 3NF, because there is no transitive

dependencies. Every 2NF can be reduced into 3NF by decomposing it further and removing any

transitive dependency.

4. Boyce-Codd Normal FormThe previous normal forms assumed that there was just one candidate key in the relation and thatkey was also the primary key. Another class of problems arises when this is not the case. Veryoften there will be more candidate keys than one in practical database designing situation. To beprecise the 1NF, 2NF and 3NF did not deal adequately with the case of relations that had two ormore candidate keys, and that the candidate keys were composite, and they overlapped(i.e. had at least one attribute common).A relation is in BCNF (Boyce-Codd Normal Form) if and only if every nontrivial, leftirreducibleFD has a candidate key as its determinant. OrA relation is in BCNF if and only if all the determinants are candidate keys.

5. Fifth Normal FormIt seems that the sole operation necessary or available in the further normalization process is thereplacement of a relation in a nonloss way by exactly two of its projections. This assumption hassuccessfully carried us as far as 4NF. It comes perhaps as a surprise, therefore, to discover thatthere exist relations that cannot be nonloss-decomposed into two projections but can be nonlossdecomposedinto three (or more). An unpleasant but convenient term, we will describe such arelation as "n-decomposable" (for some n > 2) - meaning that the relation in question can benonloss-decomposed into n projections but not into m for any m < n.A relation that can be nonloss-decomposed into two projections we will call "2-decomposable"and similarly term “n-decomposable” may be defined.

Q4. Design an E/R diagram for the following situation:We wish to model cities, counties and states in the US. For states, we wish to record thename, population, and state capital (which would be a city). For counties, we wish to

Page 12: DMS Assignment

record the name, the population, and the state in which it is located. For cities, we wish torecord the name, the population, the state in which it is located and the county/counties inwhich it is located. Names of states are unique. Names of counties are only unique withina state (e.g. 26 states have counties called "Washington"), and cities are likewise uniqueonly within a state (e.g., there is a city called "Lafayette" in Lousiana as well as Indiana).Some counties and cities have the same name, even within a state (example: SanFrancisco). Almost all cities are located within a single county, but some (e.g., New YorkCity) extend over several counties.

Assignment C

Part A –( Q1-Q20)

Belongs-to

Ci. nameCi. Popu.

Capital

Co. nameCo. Popu.

Located - in1

NamePopu.

StatesCounties

Cities

Page 13: DMS Assignment

1. What does acronym SQL stands for?a) Standardized Query Languageb) Structured Query Languagec) Simple Query Language

2. List at least three examples of one-to-many relations:a) mother and children, currency and bank account, inhabitants of townb) authors and books, prime ministers and countries, client and rented carc) students and courses, currency and bank account, flight and tourist

3. SELECT - SUM( ) - FROM - GROUP BYa) is the projective queryb) is the action queryc) is used for creating queries which divide items into groups according to a givenattribute and an aggregate function

4. Which are the basic types of DB models?a) networked, structured, centralizedb) networked, hierarchical, relationalc) relational, hierarchical, actiond) aggregate, projective, action

5. Key word DISTINCT will:a) sum different datab) list different values only oncec) add the distinct valuesd) none of these

6. What does acronym DBMS stands for?a) Database Management Systemb) Database Management Structurec) Database Management Standardsd) Database Management Studies

7. Keyword COUNT when used in query will:a) group dynaset by defined attributesb) answer the question "How many...?"c) answer the question "What is the sum of ...?"

8. DML stands for:a) Database Management Languageb) Data Manipulation Languagec) Data Multiplication Languaged) None of these

Page 14: DMS Assignment

9. Which format does not belong to the type of Number:a) integerb) scientificc) currency

10. Basic table structure is defined by:a) attributes, fieldsb) attributes, fields, valuesc) records, fields, values

11. John is working in the customer table and needs to know what customers are located inFlorida. To find the information, he would.a) create a new tableb) create a new queryc) create a new formd) utilize the Database Wizard

12. Where does the DBMS store the definitions of data elements and their relationships?a) Data fileb) Data dictionaryc) Indexd) Data map

13. When the DBMS translates logical requests into commands that physically locate andretrieve the requested information, it is fostering data ____.a) Integrityb) Inconsistencyc) Independenced) Mining

14. All of these are true about a database excepta) it is a shared, integrated structureb) it must contain multiple tablesc) it stores user datad) iit stores metadata

15. Metadata is:a) raw factsb) user created datac) data about datad) warehoused data

16. The DBMS stores definitions of the data elements and their relationships in a:a) fixed length recordb) data dictionaryc) fixed length field

Page 15: DMS Assignment

d) information diary

17. ____ is defined as "the condition in which all of the data in the database are consistentwith the real-world events and conditions."a) data dictionaryb) data integrityc) data anomalyd) data processing

18. ____ is a DBMS function in which the DBMS creates and manages the complexstructures required for data storage.a) data dictionary managementb) backup and recovery managementc) data storage managementd) database communication interfaces

19. The ___________ manages interaction between the end user and the database.a) DM query engineb) DBMQc) DBMSd) DP

20. The hierarchical database model is based on a ____.a) Tree Structureb) Lack of a child segmentc) Lack of a parent segmentd) Matrix

Part B (Q21-40) Table Name = Library

No. Title Author Type Pub Qty. Price (Rs.)

1 Data Structure Ajeet DS McGraw 4 2172 Computer Studies Shivam FND Galgotia 2 753 Adv. Pascal Vivek PROG McGraw 4 3504 DBASE dummies Shivani DBMS PustakM 5 1305 Mastering C++ Manav PROG BPB 3 2956 Guide Network Robin NET ZPress 3 2007 Mastering Access Divjot DBMS BPB 2 1358 DOS Guide Ankit OS PH1 3 1759 Basic for Beginners Ankita PROG BPB 3 40

10 Windows Guide Malvika OS BPB 1 225

Write SQL commands1. To create the above table structure with proper constraints.

MySQL> CREATE TABLE Library (

column1 No_Int[(Not Null)] constraint,

Page 16: DMS Assignment

column2 Title_Char[(Not Null)] constraint,

column3 Author_VarChar[(Not Null)] constraint,

column4 Type_Char[(20)] constraint,

column5 Pub_VarChar[(20)] constraint,

column6 Qty_Int[(Not Null)] constraint,

column7 Price_Int[(Not Null)] constraint,);

2. Select all the PROG type published by BPB from Library. MySQL> SELECT TYPE FROM Library

WHERE Pub = “BPB”;

3. Display a list of all books with Price more then 130 and sorted by Qty.MySQL> SELECT *

FROM LibraryWHERE price > 130.00ORDER BY Quantity;

4. Display all the books sorted by Price in Ascending Order.MySQL> SELECT *

FROM LibraryORDER BY Price ASC;

5. Display a report. Listing Book No. current value and misplacement charges for each book in the above table. Calculate the misplacement charges for all books Price*1.25MySQL> INSERT INTO Library (Misplacement_Charges int)

INSERT INTO Library VALUES (Misplacement_Charges int) WHERE Misplacement_Charges = Price*1.25;

MySQL> SELECT *FROM LibraryWHERE Misplacement_Charges = Price*1.25ORDER BY Title;

6. Count the number of books published by PHIMySQL> SELECT *

FROM LibraryWHERE Pub = PHIORDER BY Quantity;

7. Insert a new book in the Library.MySQL> INSERT INTO Library VALUES (‘11’, ‘Title of Book’, ‘Author of Book’, ‘Type of Book’, ‘Pub of Book’, ‘Qty. of Book’, ‘Price of Book’); 8. Count the no of books in each Type.MySQL> SELECT COUNT (DISTINCT publisher)

Page 17: DMS Assignment

FROM LibraryGROUP BY TypeORDER BY Quantity;

9. Add one more attribute “No_of_copies” in the above table.MySQL> INSERT INTO Library VALUES (no_of_copies int);

10. Update the new attribute value with 2 for each book.MySQL> UPDATE Library VALUES (no_of_copies int);

11. Count the total number of Publishers.MySQL> SELECT COUNT (DISTINCT pub)

FROM LibraryGROUP BY PubORDER BY Quantity;

12. Drop table Library.MySQL> DROP Table Library;

Give the Output of the following SQL commands.1. Select Count(Distinct Pub) from LibraryDisplay a list of “Total no of publisher”

2. Select MIN(price) from Library where price<150Display a list of all books with Price less then 150.

3. Select qty, SUM(qty) from Library GROUPBY Type.Display all type of books and and sorted by Qty and Type.

4. Select AVG(price) from Library where qty<3.Display average price of books Where qty of books less then three

5. Select * from Library where Qty IN(Select average(Qty) from Library));Display quantity of books

Write relational algebraic expression for :1. Find all books of Prog type.Select task from library where type=program;

2. Find Pub, who publish FND Books.Select Publisher from Library where publisher=FND;

3. Find all the PROG type published by PHI from Library.Select task from library where publisher= PHI AND type=PROG;