+ All Categories
Home > Documents > drronakpanchal.files.wordpress.com€¦ · Web view2nd Normal Form (2NF): A table is in 2NF if is...

drronakpanchal.files.wordpress.com€¦ · Web view2nd Normal Form (2NF): A table is in 2NF if is...

Date post: 23-Jun-2020
Category:
Upload: others
View: 5 times
Download: 0 times
Share this document with a friend
23
April /May– 2010 Paper – 205 :Datadase Management System [12bca24,12bca21,12bca22,12bca23, 12bca25] Q.1 Answer the following questions: (any seven) 1 4 1. Define DDL , DCL, and DML with example. Ans . DDL:- Data Definition Language:- DDL Statement are used to define the database structure of schema. Example:- CREATE:- to create objects in the database. ALTER:- alter the structure of the database. DML:- Data manipulation Language:- DML statement are used to managing data or say manipulating data within schema object. Example:- SELECT:-retrieve data from the database. INSERT:-insert data into a table. DCL:- Data Control Language:- DCL statements are used to control access to data in database. Example:- GRANT:- gives users access privileges to database. REVOKE:-withdraw access privileges given within the grant command. 2. What is BCNF ? How dose it differ from 3Nf ? Ans . Boyce-Codd normal form (BCNF):- A relation is in BCNF, if and only if, every determinant is a candidate key. The difference between 3NF and BCNF is that for a
Transcript
Page 1: drronakpanchal.files.wordpress.com€¦ · Web view2nd Normal Form (2NF): A table is in 2NF if is in 1NF and if all non-key attributes are dependent on all of the key. Since a partial

April/May– 2010 Paper – 205 :Datadase Management System [12bca24,12bca21,12bca22,12bca23,12bca25]

Q.1 Answer the following questions: (any seven) 141. Define DDL , DCL, and DML with example.Ans. DDL:-

Data Definition Language:- DDL Statement are used to define the database structure of schema.

Example:- CREATE:- to create objects in the database. ALTER:- alter the structure of the database.DML:-

Data manipulation Language:- DML statement are used to managing data or say manipulating data within schema

object.Example:- SELECT:-retrieve data from the database. INSERT:-insert data into a table.DCL:-

Data Control Language:- DCL statements are used to control access to data in database.

Example:- GRANT:- gives users access privileges to database. REVOKE:-withdraw access privileges given within the grant command.

2. What is BCNF ? How dose it differ from 3Nf ?Ans. Boyce-Codd normal form (BCNF):-

A relation is in BCNF, if and only if, every determinant is a candidate key.

The difference between 3NF and BCNF is that for a functional dependency A à B, 3NF allows this dependency in a relation if B is a primary-key attribute and A is not a candidate key, whereas BCNF insists that for this dependency to remain in arelation, A must be a candidate key.

3. What is the different between super key and candidate key ?Ans. Super Key :

It is require to uniquely identify the row or say entities. The key with uniquely identify the entities called super key.Example : Customer id attribute of entity set customer is sufficient to distinguished one customer

to other.so, customer is called super key. But attributes customer is not super key because two customer may have same name.Candidate key: The concept of supper key is not sufficient for our purpose so we require candidate

key. Combination of attribute customer name and ID are say to be candidate key.by this we

Page 2: drronakpanchal.files.wordpress.com€¦ · Web view2nd Normal Form (2NF): A table is in 2NF if is in 1NF and if all non-key attributes are dependent on all of the key. Since a partial

distinguished the customer entity set.4. What are object-based logical models ? Describe any one.Ans. Describe data at the conceptual and view levels.

Provide fairly flexible structuring capabilities. Allow one to specify data constraints explicitly.

CUSTOMER

NAME

STRRET

CITY

CUSTACCT ACCOUNT

NUMBER BALANCE

CUSTOMER

NAME

STRRET

CITY

CUSTACCT ACCOUNT

NUMBER BALANCE

Entity-relationship model. Object-oriented model. Binary Model. Semantic data model. Info logical model. Functional data model.

5. What is trivial and non-trivial function dependency ?Ans. Trivial dependency :

A FD X->Y is said to be a trivial functional dependency if Y is subset of X. Non-trivial dependency :A FD X-> Y is said to be a non trivial functional dependency if Y is NOT subset of X.

6. What is data abstraction ? Mention its level .Ans. Data abstraction:-

It concerns with the design of complex data structure of the representation of the data in the database.

There are three types of data abstraction:- (1) Physical level (2) Logical level (3)View level

Physical level: describes how a record (e.g., customer) is stored. Logical level: describes data stored in database, and the relationships among the

data.type customer = record customer_id:string; customer_name:string;customer_street:string;customer_city : string;

Page 3: drronakpanchal.files.wordpress.com€¦ · Web view2nd Normal Form (2NF): A table is in 2NF if is in 1NF and if all non-key attributes are dependent on all of the key. Since a partial

View level: application programs hide details of data types. Views can also hide information (such as an employee’s salary) for security purposes.

Q-2 What is data dictionary ? How the data dictionary is maintained ?Discuss integrity related issues pertaining to data dictionary.

8

Ans:

(b) Define relationship. Explain type of relationship with example.Ans: Relationship :-

What do you mean by normalization ? Explain BCNF in detail. Ans: Normalization :-

Normalization is the process of efficiently data in a database. There are two goals of the normalization process: eliminating redundant data (for example, storing the same data in more than one table) and ensuring data dependencies make sense (only storing related data in a table). Both of these are worthy goals as they reduce the amount of space a database consumes and ensure that data is logically stored.

Normalization can be viewed as a series of steps designes, one after another, to deal with ways in which tables can be “too complicated

Page 4: drronakpanchal.files.wordpress.com€¦ · Web view2nd Normal Form (2NF): A table is in 2NF if is in 1NF and if all non-key attributes are dependent on all of the key. Since a partial

for their own good”. The purpose of normalization is to reduce the chances for anomalies

to occur in a database. The definitions of the various levels of normalization illustrate complications to be eliminated in order to reduce the chances of anomalies.

At all levels and in very case of table with a complication, the resolution of the problem turns out to be the establishment of two or more simpler tables which, as a group contain the same information as the original table, but because of their simpler individual structures, lake the complication.

Pros of normalization Cons of normalization

More efficient database structure.

Better understanding of your data.

More flexible database structure.

Easier to maintain database structure.

Few (if any) costly surprises down the road.

Validates your common sense and intuition.

Avoid redundant fields.

Insure that distinct tables exist when necessary.

You can’t start building the database before you know what the user needs.

1st Normal Form (1NF):A. ) Table (relation) is in 1NF if:

1. There are no duplicated rows in the table.2. Each cell is single-valued (no repeating groups or arrays).3. Entries in a column (field) are of the same kind.

The requirement that there be no duplicated rows in the table means that the tables has a key (although the key might be made up of more than one column, even possibly, of all the columns

2nd Normal Form (2NF):

Page 5: drronakpanchal.files.wordpress.com€¦ · Web view2nd Normal Form (2NF): A table is in 2NF if is in 1NF and if all non-key attributes are dependent on all of the key. Since a partial

A table is in 2NF if is in 1NF and if all non-key attributes are dependent on all of the key. Since a partial dependency occurs when a non-key attribute is dependent on only a part of the composite key, the definition of 2NF is sometimes phrased as, “A table is in 2NF if it is in 1NF and if it has no partial dependencies”.

3rd Normal Form (3NF):A table is in 3NF if it is in 3NF and if every determinant is a candidate key.

Boyce-Codd Normal Form (BCNF):A table is in BCNF if is in 3NF and if every determinant is a candidate key.

4th Normal Form (4NF):A table is in 4NF if it is in BCNF and if it has no multi-valued dependencies.

5th Normal Form (5NF):A table is in 5NF, also called “Projection-join Normal Form” (PJNF), if it is in 4NF and if every join dependency in the table is a consequence of the candidate keys of the table.

Page 6: drronakpanchal.files.wordpress.com€¦ · Web view2nd Normal Form (2NF): A table is in 2NF if is in 1NF and if all non-key attributes are dependent on all of the key. Since a partial

Q.3 Write notes on following (any three) 21(1) Discuss lossless-join decomposition.Ans:(2) Explain specialization and Aggration in details.Ans: Specialization:-

An entity set may include subgroupings of entities that are distinct in some way from other entities in entity set.

For instance, a subset of entities within an entity set may have attributes that are not shared by all the entities in the entity set. The e-r model provides a means for represeting these distinctive.

Page 7: drronakpanchal.files.wordpress.com€¦ · Web view2nd Normal Form (2NF): A table is in 2NF if is in 1NF and if all non-key attributes are dependent on all of the key. Since a partial

As an example, consider an entity set person, with attributes person_id, name, street and city. A person may be further classified as one of the following: (a) customer (b) employee

Each of these person type is described by a set of attributes that includes all the attributes of entity set person plus possibly additional attributes.

For example,customer entities may be described further by the an attribute credit_rating, whereas employee entities may be describe further by the attribute salary. the process of designating subgroupings within an entity set is called specialization.

E-R DIAGRAM FOR SPECIALIZATION:-

Aggregation: Consider the ternary relationship works-on, which we saw earlier. Suppose we want to record managers for tasks performed by an employee at a

branch.

Page 8: drronakpanchal.files.wordpress.com€¦ · Web view2nd Normal Form (2NF): A table is in 2NF if is in 1NF and if all non-key attributes are dependent on all of the key. Since a partial

n Relationship sets works-on and manages represent overlapping informationn Every manages relationship corresponds to a works-on relationship

H However, some works-on relationships may not correspond to any manages relationships

4 So we can’t discard the works-on relationshipn Eliminate this redundancy via aggregation

H Treat relationship as an abstract entityH Allows relationships between relationships H Abstraction of relationship into new entity

n Without introducing redundancy, the following diagram represents:H An employee works on a particular job at a particular branch H An employee, branch, job combination may have an associated manager

(3) Explain Entity set types of attributes in detail.

Page 9: drronakpanchal.files.wordpress.com€¦ · Web view2nd Normal Form (2NF): A table is in 2NF if is in 1NF and if all non-key attributes are dependent on all of the key. Since a partial

Ans: Entity set:-An entity is represented by a set of attributes, that is descriptive properties possessed by all members of an entity se

Attribute types. Simple and composite Attribute Single-value and multi-value attribute Null attribute Derived attribute

Simple and composite avttribute Simple attribute The attribute have been simple that is they are not drivided into subparts.

Example: basic Price Amount

Composite attributeComposite attribute can be divided into subparts.Example

Address

Street City State zipCode

Single-valued and multi valued Attribut Single – value Attribute

The attribute all have a single value for a particular entity.ExampleThe lon _number attribute for a specific loan,entity-refers to anlyon loan number.

The register no of student is refers only one student Such attributes are said to be single valued.

Multi –value AttributeTher may be instances where an attribute has set of value for specific entity.The register on student is refers only one studentExampleEmployee table having attribute telephone no.Employee may have many telephone no like mobile no, office no, home no telephone no, or may possible that employee have two mobile no.

Page 10: drronakpanchal.files.wordpress.com€¦ · Web view2nd Normal Form (2NF): A table is in 2NF if is in 1NF and if all non-key attributes are dependent on all of the key. Since a partial

It is called multi values attribute because there are many values telephone no Employee table having e-mail address.If may possible that employee having two of more e-mail address.so e-mail address is also multi valued attribute

Null attribute A null value is used when an entity dose not have a value for an attribute.Null means the attribute value is unknown ,missing or not know,A null value for apt_number coluld not mean that the address dose not include apartment number,in this apt_number is exists but user doesn’t know.

Derived attribute.The value for this type of attribute can be derived from the value of other related attributes or entities Example:-Student data of birth is given in the attribute DOB so we can calculate the age of student by data of birth. So we can new attribute Age from the attribute DOB.

So we say that age is derived from DOB. Age is called derived attribute.

Customer entity set has an attributes loans_ held, which represents how many loans a customer has from the bank. we can derive the value for this attribute by counting the no. of loan entities associated with that customer.

(4) Explain different types of keys.Ans: There are different types of keys:-

(I) Super Key(II) Candidate Key(III) Primary Key(IV) Foreign Key(V) Composite Key(VI) Alternate Key(VII) Secondary Key

(VIII) Super Key:-

An attribute or a combination of attribute that is used to identify the records uniquely is known as Super Key. A table can have many Super Keys. E.g. of Super Key 1 ID2 ID, Name3 ID, Address4 ID, Department_ID5 ID, Salary

Page 11: drronakpanchal.files.wordpress.com€¦ · Web view2nd Normal Form (2NF): A table is in 2NF if is in 1NF and if all non-key attributes are dependent on all of the key. Since a partial

6 Name, Address7 Name, Address, Department_ID ………… So on as any combination which can identify the records uniquely will be a Super Key.

(II) Candidate Key – It can be defined as minimal Super Key or irreducible Super Key. In other words an attribute or a combination of attribute that identifies the record uniquely but none of its proper subsets can identify the records uniquely. E.g. of Candidate Key1 Code2 Code,NameFor above table we have only two Candidate Keys (i.e. Irreducible Super Key) used to identify the records from the table uniquely. Code Key can identify the record uniquely and similarly combination of Code and Name can identify the record uniquely, but neither Code nor Name can be used to identify the records uniquely as it might be possible that we have two employees with similar name or two employees with the same name.

(III) Primary Key – A Candidate Key that is used by the database designer for unique identification of each row in a table is known as Primary Key. A Primary Key can consist of one or more attributes of a table.

A primary key is a column (or columns) in a table that uniquely identifies the rows in that table. CUSTOMERSCustomerNo

FirstName

LastName

1 Sally Thompson

2 Sally Henderson

3 Harry Henderson

4 Sandra Wellington

Page 12: drronakpanchal.files.wordpress.com€¦ · Web view2nd Normal Form (2NF): A table is in 2NF if is in 1NF and if all non-key attributes are dependent on all of the key. Since a partial

For example, in the table above, CustomerNo is the primary key.

The values placed in primary key columns must be unique for each row: no duplicates can be tolerated. In addition, nulls are not allowed in primary key columns.

E.g. of Primary Key - Database designer can use one of the Candidate Key as a Primary Key. In this case we have “Code” and “Name, Address” as Candidate Key, we will consider “Code” Key as a Primary Key as the other key is the combination of more than one attribute.

(IV) Foreign Key – A foreign key is an attribute or combination of attribute in one base table that points to the candidate key (generally it is the primary key) of another table. The purpose of the foreign key is to ensure referential integrity of the data i.e. only values that are supposed to appear in the database are permitted.

E.g. of Foreign Key – Let consider we have another table i.e. Department Table with Attributes “Department_ID”, “Department_Name”, “Manager_ID”, ”Location_ID” with Department_ID as an Primary Key. Now the Department_ID attribute of Employee Table (dependent or child table) can be defined as the Foreign Key as it can reference to the Department_ID attribute of the Departments table (the referenced or parent table), a Foreign Key value must match an existing value in the parent table or be NULL.

(V) Composite Key – If we use multiple attributes to create a Primary Key then that Primary Key is called Composite Key (also called a Compound Key or Concatenated Key). E.g. of Composite Key, if we have used “Name, Address” as a Primary Key then it will be our Composite Key.

(VI) Alternate Key – Alternate Key can be any of the Candidate Keys except for the Primary Key. E.g. of Alternate Key is “Name, Address” as it is the only other Candidate Key which is not a Primary Key.

(VII) Secondary Key – The attributes that are not even the Super Key but can be still used for identification of records (not unique) are known as Secondary Key. E.g. of Secondary Key can be Name, Address, Salary, Department_ID etc. as they can identify the records but they might not be unique.

Q.4 Answer the following questions: 6a. Construct an E-R diagram for a car insurance compant whose customer own one or

more cars each. Each car has associated with it zero to any number of recorded accidents.

Page 13: drronakpanchal.files.wordpress.com€¦ · Web view2nd Normal Form (2NF): A table is in 2NF if is in 1NF and if all non-key attributes are dependent on all of the key. Since a partial

Ans. The entity relationship data model is based on a perception of a real world that consists of a collection of basic objects called enities and of relationship among these objects.

An entity is a “thing” osr “object” in the real world that is distinguishable from other objects.

Person is an entity and bank account can be considered. A relationship is an association among several entitles.

The overall logical structer of a database can be expressed graphically by an ER diagram, which is built up from the following components

THE ER Diagram Symbols:Rectangles Which represent entity set

Ellipses Which represent attributes

Diamonds Which represent relationship among entity sets

Lines Which link attributes to entity set and entity sets to relationship

Double Ellipses Multivalued attributes

Page 14: drronakpanchal.files.wordpress.com€¦ · Web view2nd Normal Form (2NF): A table is in 2NF if is in 1NF and if all non-key attributes are dependent on all of the key. Since a partial

Dash Ellipse Derived attributes

Double Rectangle Weak entity

soss

ORConstruct an ER diagram for a hospital with a set patients and set of medical doctors. Associate with each patient a log of the various tests and examination conduct

customer account

street

addcust

city

depositor

account balance

social

Page 15: drronakpanchal.files.wordpress.com€¦ · Web view2nd Normal Form (2NF): A table is in 2NF if is in 1NF and if all non-key attributes are dependent on all of the key. Since a partial

Ans

(b) Explain following. (1) How to set relationship between table in access ? 4Ans:

Relationship : A relationship is an association among seneral enities.

Example :- Manufacturer and products.

The image shows the creation of a simple products table in MS-Access. Here we are setting

up what information we want to store for each product we will have in our inventory, obviously there would be much more information in a real-world case. Notice the first field we defined in our table (id). We created the id field setting its data-type to AutoNumber. This means that every time we insert a record into our table the value in the id column will increment by 1. This automatically creates a unique value for each and every

patients doctors

P_ no

Phon_ no

dob

age

dname

dtypeTest-tyoe

Admit D_id

test_ no

P name

Page 16: drronakpanchal.files.wordpress.com€¦ · Web view2nd Normal Form (2NF): A table is in 2NF if is in 1NF and if all non-key attributes are dependent on all of the key. Since a partial

(2) What is check constraint ? how to define it ? 2OR

(1) What is check constraint ? How to define it ? 4(2) How to primary key define on table ? 2Q.5 Consider following relations in database and solve the queries. 12

Ans:- Book _master (Book _ no, book _ name, author, publisher, no _ of _copy) Create the table book_master

(Book _no number primary key,Book _name text,Author text,Publisher text ,N0_of_copy number);Stud _master(lib_ no, stud _name, book_ no, No_ Of_ copy)Create the table stud_ master(Lib_ no number,Stud_ name text,Book_ no number references book_ master,No _0f_copy number); Transaction ( trans _no , trans_ type, lib_ no , book_ no ,no_ of _copy, trans_ date)Create the table transaction(Trans_ no number ,Trans_ type text,Lib_ no number,Book_ no number,No _of_ copy number,Trans _date date time);

(1) Display all student name who have more then two books.Ans : select* From stud_ master, Book _Master Where stud_ name(2) Display all books whose publisher is “ BPB”.Ans:- select * From book_master

Page 17: drronakpanchal.files.wordpress.com€¦ · Web view2nd Normal Form (2NF): A table is in 2NF if is in 1NF and if all non-key attributes are dependent on all of the key. Since a partial

Where publisher like=”bpb”;(3) Display all students who have “DBMS” book.Ans :- select * From stu_master Where book_name like “dbms”;(4) Delete records from stud _mast for all students who have “ORACLE” book.Ans:- delete * From stud_mast Where book_name like”oracle”;(5) Change transction type to “R” (return ) for all transaction whose transaction type is “I”(issue) and b00_ name=”Let US C”.Ans :- update transaction Set trans_types=”r” Where trans_type=”I” and book_name=”let us c”(6) Display all student name who get book publisher “BPB”Ans:- delete * From stud_ mast , book_ name Where book publisher like “BPB”;


Recommended