Databases Ys

Embed Size (px)

Citation preview

  • 7/29/2019 Databases Ys

    1/75

    Module-II

    Database and databasemanagement system

  • 7/29/2019 Databases Ys

    2/75

    Difference between files and Relationaldatabase

    Files1. Store data in one

    dimensional files

    2. Stores, organize

    and retrieveinformation fromone file at a time

    3. Leave the

    management ofdata relationshipsto the applicationsthat access the

    data.

    Relational database1. Store data in twodimensionaltables

    2. Store organizesand retrieveinformation islinked by acommon columnor field

    3. Establishrelationshipsbetween files andviews within the

    database itself.

  • 7/29/2019 Databases Ys

    3/75

    4. Require aprogrammer towrite code for datamanagementfunctions.

    5. Files are createdand maintained byapplicationprograms.

    6. Are often

    associated witholder programs onmainframe andmid-range system.

    4.Are typically createdand maintained by

    databaseadministrators.

    5.Are popular on

    UNIX processorsand powerful serverwithin aclient/server

    framework6. Consists a database

    engine thatperforms differentfunctions.

  • 7/29/2019 Databases Ys

    4/75

    Database

    Database is an integrated and well defined

    data and information,centrally controlled in allits aspects,created and stored in atypicalstructure for an organization.

    In an organization the database could be one

    or more depending upon the needs and theoperations of the organization.

    The data structure and its storage should besuch that it facilitates

    sharability,availability,and integrity of data.Database excludes transient data such asreports,input documents,intermediate resultsobtained during processing

  • 7/29/2019 Databases Ys

    5/75

    Objectives of Database

    1. Controlled Redundancy

    2. Ease of learning and use

    3. Data independence4. More information at low cost

    5. Accuracy and integrity

    6. Recovery from failure7. Privacy and security

    8. Performance

  • 7/29/2019 Databases Ys

    6/75

    Advantages of Database Approach

    All the three levels of management use thesame database hence any report using the

    information will be consistentAll the three levels of management view thedatabase as per their needs.

    The application systems can be developedindependent of the database.The data validation and updating will be onceand same for all

    The data is shared by all userData security and privacy can be managed

    AS the database is a storage of structuredinformation the queries can be answered fast.

  • 7/29/2019 Databases Ys

    7/75

    User programs

    Application program or queries

    Software to process

    Queries/Programs

    S/W to access

    Stored Data

    Stores

    database

    definition

    Stored data

    base

  • 7/29/2019 Databases Ys

    8/75

    Major types of databases used byOrganization and users

    Computer using organizations havefive types of databases.

    1. Common operational database

    2. Common end user database

    3. Distributed database

    4. Personal and end user databases and5. External database

  • 7/29/2019 Databases Ys

    9/75

    databases

    These databases consists of avariety of data files developed byend users at their

    workstations.Users may have theirown electronic copies ofdocuments they generated withword processing packages orreceived by e-mails, fromelectronic spreadsheets and DBMSpackages.

  • 7/29/2019 Databases Ys

    10/75

    Distributed databaseThese are databases of local work groupsand departments at regional office,branchoffices manufacturing plant and other worksites.These database can include segments

    of both common operational and commonuser databases as well as data generatedand used only at a users own site.

  • 7/29/2019 Databases Ys

    11/75

    Common operational databaseThese databases store detaileddata needed to support theoperation of entire

    organization.They also calledsubject areadatabases,transaction databases

    and production databases.For example Customerdatabase,personnel

    database,accounting database

  • 7/29/2019 Databases Ys

    12/75

    These databases store data and

    information extracted from selectedoperational and external databases.theyconsists of summarized data andinformation most needed by theorganisation managers and other endusers.They are also called informationdatabases and management databases

    and accessed by executive and users aspart of DSS And EIS to supportmanagerial decision making.

  • 7/29/2019 Databases Ys

    13/75

    External databases

    These can be accessed from large,privatelyowned databases or databanks available fora fee to end users and organisations fromcommercial information service

    networks.Data is available in the form ofstatistics on economic and demographicactivity from statistical data banks; abstracts

    from hundreds of newspapers,magazines andother periodicals from bibliographic databanks.

  • 7/29/2019 Databases Ys

    14/75

    Data base management system

    DBMS is a collection of programs that enables users to create and maintain

    a database.The DBMS is a general purpose software system that facilitatesthe processes of defining,constructing and manipulating databases forvarious applications.

    Defining database involves specifying the data type structures andconstraints for the data to be stored in the database.

    Constructing the database is the processes of storing the database itselfon the storage medium that is controlled by DBMS.

    Manipulating includes the updating of database or editing the databaseand generating reports from the data.

    The DBMS is a S/W or a set of rules and methods that allows for

    defining,creating,updating,reading ,maintenance and protection ofthe database.

  • 7/29/2019 Databases Ys

    15/75

    DBMS consists of a collection of inter-related

    data and a set of programs to access thatdata.The collection data is usually referred toas database which contains information aboutone particular enterprise.

    The primary goal of a DBMS is to provide anenvironment that is both convenient andefficient to use retrieving and storing database

    information.DBMS is the interface between the user ofapplication programs on one hand and the

    database on other.

  • 7/29/2019 Databases Ys

    16/75

    DBMS

    DBMS as interface between applicationprogram and data base

    User(or)

    Application

    program

    DBMS Data base

  • 7/29/2019 Databases Ys

    17/75

    Major users of a DBMSpackage

    Database integration and reporting

    Application development

    Database access and maintenance

    Database creation and modification

  • 7/29/2019 Databases Ys

    18/75

    Components to a DBMS

    These are:-

    1. At least one person who owns' and isresponsible for the database.

    2. A set of rules and relationships that defines

    and governs the interactions amongelements of the database.

    3. People who put data into the database

    4. People who get data out of the database5. The database itself.

  • 7/29/2019 Databases Ys

    19/75

    Components of DBMS

    DDL

    DML

    SQL

    f

  • 7/29/2019 Databases Ys

    20/75

    Functions of DBMS

    1. Organizes data:-Data are organised according to thespecifications of DDL.These are specified by the DBA at thetime of creation of database.

    2. Integrates data:- Data are interrelated or linked together atthe elements level and can,therefore be assembled in manycombinations during execution of a particular applicationprogram.

    3. Separates data:-A DBMS servers as a filter betweenapplication program and their associated data.It separatesthe logical description and relationship of data from the wayin which the data are physically stored.

    4. Controls data: A DBMS appears to an applicationprogrammer to be an extension of the O.S S/W .As it receivesdata requests from host programs,it controls how and where

    data are physically stored.5. Retrieves data:A record of data can be obtained via

    DBMS1.Serially 2.Sequentially 3.Randomly by address4.Randomly by key 5. By structural link

    6. Protects :A DBMS protects and secures both the content ofa database and relationships of data element . Data areprotected against by unauthorized users,physical damage,OS

  • 7/29/2019 Databases Ys

    21/75

    Data dictionary1. It is an encyclopedia of information concerning each

    data element.It describes the data and its

    characteristics,such as location,size,type of data,itidentifies the origin,the use,the ownership,and themethod of accessing and securing data.

    2. The data dictionary can exist either on paper or as a

    computer file.When it exist as a file,special S/W isnecessary to create and maintain it,and make itavailable for use such S/w is called a data dictionarysystem(DDS).DDSs can be acquired as separate S/W

    packages or as DBMSs and computer aided S/Wengineering tools.

    3. A good data dictionary would ensure consistentdefinitions of data across different databases,and if

    there were a change to the data ,it would also

  • 7/29/2019 Databases Ys

    22/75

    Benefits of databasemanagement system

    Reduced programming cost

    Reduced Development and

    implementation timeReduced program and file managementcosts.

    Reduced data redundancy

    Increased flexibility

  • 7/29/2019 Databases Ys

    23/75

    Language

    Two languages are used to communicatewith data base are:

    1. Data description Language(DDL)2. Data manipulation Language(DML)

    r

  • 7/29/2019 Databases Ys

    24/75

    rLanguage(DDL)

    It is used to create and describe the data anddefine the schema in a DBMS

    It serves as an interface for applicationprograms that use the data.Once the data

    dictionary has been created its definition must bentered into the DBMS.

    For example,if a payroll program needs the

    employment number of an employee the DDLdefines the employment number and the otherdata in the database and acts as an interfacebetween the payroll program and the files that

    contain the employment number

  • 7/29/2019 Databases Ys

    25/75

  • 7/29/2019 Databases Ys

    26/75

    Structured Query Language

    It is a non procedural language exclusivelydeals with data:

    Data integrity

    Data manipulationData access

    Data retrieval

    Data queryData security

  • 7/29/2019 Databases Ys

    27/75

    SQLIt allows the user to access the data from the

    databases to specific queries,both onmainframes and on PCs.Here users cantransform their experience from one database

    system to another without going into muchdetail.

    There are four basic operation in SQL

    1. Select2. Update

    3. Insert

    4. And delete

  • 7/29/2019 Databases Ys

    28/75

    Select statement enables users to query the database forspecific information

    Update statement allow users to update the data.

    Insert statement new data in the existing database.

    Delete statement delete existing data from the database

    Two types of question s can be asked by users in SQL:

    -Static Question & dynamic Question

    Static questions are routine and standardize and oncedefined,can be used repeatedly or generatingweekly,monthly and quarterly reports, S/W packagesgenerating static questions are sometimes referred to asreport writers.

    Dynamic questions are ad hoc and specific to thedecision maker.

    Characteristics of DBMS

  • 7/29/2019 Databases Ys

    29/75

    Characteristics of DBMSThe capability to store large amounts of datanecessary for users needs.They are stored ondirect accessible devices for on-line support.

    The capacity to interrogating data files,retrievingand modifying data and recording the changes

    The data are combined to form operational unitsto minimise the duplication of data and increaseaccess to all data in the database.

    The control in the systems limits the access to thedatabase files and builds the confidentiality of alldata in these files.

    Objectives of DBMS

  • 7/29/2019 Databases Ys

    30/75

    Objectives of DBMSProvide for mass storage of relevant data.

    Make access to the data easy for the userProvide prompt response to user requests for data.

    Make the latest modifications to the data baseavailable immediately

    Eliminate redundant Data

    Allow for multiple users to be active at one time

    Allow for growth in the database system

    Protect the data from physical harm andunauthorised access

  • 7/29/2019 Databases Ys

    31/75

    Major uses of DBMS

    The four major uses of a DBMS packageare:

    1. Database interrogation and reporting(forend users)

    2. Application development(for end users andprogrammers)

    3. Database access(for end users andinformation service staff)4. Database creation and modification(for end

    users and database administrators)

  • 7/29/2019 Databases Ys

    32/75

    Data Independence

    The ability to modify a schemadefinition in one level without affectinga schema definition in the next higherlevel is called data independence.

    There are two levels of dataindependence

    Physical data independenceLogical data Independence

  • 7/29/2019 Databases Ys

    33/75

    Physical data independence

    It is the ability to modify the physicalschema without causing applicationprograms to be rewritten.Modifications

    at the physical level occasionallynecessary in order to improveperformance.

    L i l d t I d d

  • 7/29/2019 Databases Ys

    34/75

    Logical data Independence

    It is the ability to modify the conceptual schemawithout causing application programs to berewritten.Modification at the conceptual level arenecessary whenever the logical structure of thedatabase is altered(addition of money-market

    accounts in banking system).It is more difficult toachieve than physical data independence sinceapplication programs are heavily dependent onthe logical structure of the data they access.Theconcept of DI is similar in many respects to theconcept of abstract data types in modern PLs .Both hide implementation details from theusers.This allows users to concentrate on thegeneral structure rather than low level

    implementations details.

  • 7/29/2019 Databases Ys

    35/75

    Data base BasicData items:-It is the smallest unit of data that

    has meaning to its user .The data item issimply known as the field in dataprocessing.It may be treated as a moleculeof the database.For example a student name

    in a database is called as a data item.Thedata item could occasionally be furtherbroken down is called atomic level forprocessing purposes.For example,a data item

    such as a data would be a composite valuecomprising the date,day and year.Forexample your registration number etc.

    In the organisation ,each department is

    responsible to find out its own way of-

  • 7/29/2019 Databases Ys

    36/75

    Entities

    All the real world object such as anemployee, a component in an inventory

    or a space or it may be intangible suchas a even,a job description,identificationnumbers.All such items about whichrelevant information is stored in thedatabase are called Entities.

  • 7/29/2019 Databases Ys

    37/75

    Attributes

    An attribute may be expressed as a numberor as a text.It may even be a scannedpicture,a sound sequence,a moving picturewhich is now possible in multimedia database

    Data processing normally concern with acollection of similar entities and records

    information about the same attributes of eachof them

    Schema

  • 7/29/2019 Databases Ys

    38/75

    SchemaA schema is a logical database description andis drawn as a chart of the types of data that areused .It gives the names of the entities andattributes and specify the relationship betweenthem.It is a frame work into which the dataitem can be fitted.Like an information display

    system such as that giving the arrival anddeparture time at airport and railwaystations,the schema will remain the samethough the value displayed in the system will

    change from time to time.The relationshipbetween the entities occurring in the schemamay be one-to-one or one-to-many or many tomany or conditional.That means it is an overall

    chart of all the data item type and record types

  • 7/29/2019 Databases Ys

    39/75

    Subschema

    The term subschema refers to the sameview but for the data-item types and

    record type which are used in aparticular user.Therefore many differentsub-schemas can be derived from oneschema

    Analysis between schema and

  • 7/29/2019 Databases Ys

    40/75

    Analysis between schema andsub schema

    If schema represent a road map ofDelhi showing the major historical sites

    ,educational institutions,railwaystations,roadway stations and airports,asubschema could be a similar mapshowing one route each from therailway station or the airport to IGNOUcampus at Maidan Garhi

  • 7/29/2019 Databases Ys

    41/75

    A general model of a database system

    External schema

    User view User viewUser view

    Conceptual Schema

    Internal Schema

    Stored data

    Three views of data

  • 7/29/2019 Databases Ys

    42/75

    Three views of dataDBMS is a collection of interrelated files and a set

    of programs that allows several users to access

    and modify these files.The concern for efficiently leads to the design of

    complex data structure for the representationof data in the data base.As the database

    system are often used by non computerprofessionals,this complexity must be hiddenfrom database system users. This is done bydefining levels of abstract as which thedatabase may be viewed,there are threeviews.

    1. Logical or External view2. Conceptual view

    3. Internal or Physical view

  • 7/29/2019 Databases Ys

    43/75

    External view or logical view

    It is the highest level of abstraction asseen by a user

    This level of abstraction describes onlythe part of entire database.

  • 7/29/2019 Databases Ys

    44/75

    Conceptual view

    This is the next higher level of abstractionwhich is the sum total of users views.Thislevel describes what data are actually stored

    in database.This level contains information about entiredatabase in terms of a small number ofrelatively simple structure.

    It represents the entities and thererelationships.

    It contains integrity rules and authorizationrules,but it does not contain informationabout how the data items are stored

  • 7/29/2019 Databases Ys

    45/75

    Internal View

    This is the lowest level of abstraction atwhich one describes how the data are

    physically stored And how we canaccess it.

    It includes information on ordering of

    records,block sizes,storage indexes,useof pointers,and access strategies beingused.

    D t B Ad i i t t

  • 7/29/2019 Databases Ys

    46/75

    Data Base AdministratorA person who is having central control over

    the data and the programs.Functions of DBA

    1. Schema definition,2. Storage structure and access method

    definition,3. Schema physical organisation for data

    access,

    4. Integrity constraint specification.5. Back up and restore database6. Monitor database performance and

    efficiency.

    File management vs database management

  • 7/29/2019 Databases Ys

    47/75

    File management vs. database management

    Topic File Management Databasemanagement

    Data redundancy May have highdegree of dataredundancy

    Has a low degreeof dataredundancy

    DataIndependence

    Recognition ofrecord format or

    access methodmeans theapplication has tobe changed

    Similarrecognition has

    little or no impacton application

    ApplicationMaintenance Highermaintenance cost Low maintenancecost

    Integrity controls Usually providedby programmer

    Provided byDBMS

    UnanticipatedQueries A customprogram has to A query languagecan be used

    on

  • 7/29/2019 Databases Ys

    48/75

    on .Datarelationship

    Handled byapplicationsif at all

    An integralpart of DBMS

    Overhead Little CPUand Storage

    overhead

    Moreprocessing

    power andstorage isneeded

    Databaseownership

    Applicationsmay havetheir ownprivate data

    All databelongs tothe DBMS

    cont

  • 7/29/2019 Databases Ys

    49/75

    cont

    DBA Not needed Needed tocoordinate and

    resolve theneeds of theusercommunity

    Availability oftrainedprogrammers

    Mostprogrammersare trained touse filemanagement

    The averageprogrammerneeds to betrained to usedatabasemanagement

    Databasedesign

    Data files maybe designed as

    needed

    More time andeffort is spent

    to develop agood databasedesign

    D t d l

  • 7/29/2019 Databases Ys

    50/75

    Data models

    A data model is a collection of concepts that

    can be used to describe the structure of adatabase.By structure of a database we meanthe data types,relationships and constraintsthat should hold on data.

    Most of the data models also include a set ofbasic operations for specifying retrievals andupdates on the database.

    A database model is the method of organizingdata and represents the logical relationshipamong data elements in database .

    D t M d l

  • 7/29/2019 Databases Ys

    51/75

    Data Models

    Data model is of three types1. Object based logical model:ER

    model,Object oriented model,binary

    model,Semantic data model,infological model,functional data model

    2. Records based logicalmodels:Relational,Network,Hierarchical

    3. Physical data model:Unifying

  • 7/29/2019 Databases Ys

    52/75

    Types of data model

    Hierarchical Model

    Net work ModelRelational model

  • 7/29/2019 Databases Ys

    53/75

    Types of Relationship

    One-to-one:This relationship indicates aunique relation between two entities(student-regd-no,person and employment no.)

    One-to-many:Here an entity can havemultiple relationships with other entities inthe database(Air bus and passengers,teacherand student)

    Many-to-many:Here every entity can berelated to a number of entities.(teachers andstudents).

    of database processing system in banking

  • 7/29/2019 Databases Ys

    54/75

    Bank database

    DBMS

    Operating System

    Application Program

    Banking Service data model

    Installment loan

    data modelChequing and

    Savings data model

    Chequing

    Application

    Installment loan

    ApplicationSaving

    Application

  • 7/29/2019 Databases Ys

    55/75

    It helps to establish explicit or logicalrelationships among various data elements of

    multiple files and arrange the elements in ahierarchy.

    Each box is a record,it is also termed asnode.

    In this model each record in one level can berelated to multiple records on the next-lowerlevel.

    A record that has a subsidiary records is

    callec the parent and the subsidiary recordsare called children.

    It follows 1:M relationship with other dataelements in the database

    Schematic of a hierarchical tree structure

  • 7/29/2019 Databases Ys

    56/75

    Entity type

    Record type

    Entity type

    The above figure provides the hierarchical model

  • 7/29/2019 Databases Ys

    57/75

    Here link fields establish the explicit relationships.

    The links are represented by thin lines that

    connect data elements of the various records inthe lower portion.

    Once a sales person record is retrieved the link inthat record can lead to another record i,e

    logically related to that salesperson.A link field inthe second record leads to a 3rd record,and so oncreating a chain through an entire set of file.

    The system retrieve records from the hierarchy

    through pointers,which are pieces of data thatidentifies the link between different records.Thedata nodes in this are linked to one anotherthrough a series of pointers,one of which isattached to the end of each record in the

    database

    Advantage Disadvantage

  • 7/29/2019 Databases Ys

    58/75

    Advantage DisadvantageWell suited for

    modelinghierarchical data.

    Top-down naturemakes

    programmingefficient.

    Based on one-way access fromsuperiors to subordinates.

    Not suited for manyto-manyrelationships.

    Difficult to inert subordinate recordswithout superior records.

    Deleting superiors logically deletessubordinates.

    Difficult to update record stored inmultiple locations.

    Not suited for databases whererelationships change.

    Network Model

  • 7/29/2019 Databases Ys

    59/75

    Network ModelIn this model,each record in a database canhave multiple parents.

    It maintain Many-to-Many(M:M) relationship

    In network model,databases can betranslated from hierarchical form to network

    form and vice-versa.Data elements are linked through pointers.

    In this model a child can have a number ofparents,where as in a hierarchical model a

    child can have only one parent.Like hierarchical model the records are notlimited to only one superior.

    A record may have many superior records

    and many subordinate records.

    Network Model

  • 7/29/2019 Databases Ys

    60/75

    Network Model

    It allows entry into a database at multipoint

    A group of interconnected nodes is called anetwork.

    A subway map is an example of a

    network.The subway stations are thenodes,and the tracks are the interconnectionsor network.

    A common approach is multi

    pointers,especially with a link node recordrepresenting the connection between twoentities.

    Advantages Disadvantages

  • 7/29/2019 Databases Ys

    61/75

    Advantages DisadvantagesIt promotes flexibilityand data

    accessibility,since dataelements at a lowerlevel can be accessedwithout accessing the

    data elements abovethem.

    It is efficient ,easy tounderstand,and can beapplied to many realworld problems thatrequire routinetransaction.

    It is complex to designand develop

    It requires that therelationships among alldata elements to bedefined before

    development starts,andchanges often demanda major programmingefforts

    For large database

    ,operation andmaintenance of thenetwork model aretime-consuming andexpensive

    Relational Model

  • 7/29/2019 Databases Ys

    62/75

    Relational ModelIn relational model , data is represented

    using two-dimensional tables,called relationof flat files

    The flat files are made up of columns androws.

    Each column represents a field,also referredto as an attribute.

    Each row represent a record , also referred as

    a tuple.It is well suited for business needs because oftheir flexibility

    Relational Model

  • 7/29/2019 Databases Ys

    63/75

    Relational ModelRelational databases use three fundamentaloperations:

    SELECT

    PROJECT

    JOIN

    The select operation is used to selected therequested query.

    The project operation creates a subset ofcolumns designed to meet the information

    needs of the user.The JOIN operation joins or links two or moretables ,if the information requested by theuser is not found in one table

    Example:MS Access,dbase IV,DB2

    Advantages Disadvantages

  • 7/29/2019 Databases Ys

    64/75

    Advantages DisadvantagesQuery languages allow easeof use.

    It can relate data in a tableas long as the two tablesshare at least one commonattribute.Thats why mostcommercial databases for

    microcomputers use relationaldatabase

    It enables a computer systemto accommodate a variety offile inquiries in an efficientmanner.

    No need to know the innerstructure of the database

    Data independence allow easy

    structure modification

    Query languagesconsume processing

    time and memory

    Data must be related toact upon

    Set processing is not

    suite3d to conventionalPLs.

    Command affectsystem performance

    Relational Database

  • 7/29/2019 Databases Ys

    65/75

    Relational Database

    A DBMS can be regarded as relational only

    if it obeys the following three rules.1. All information must be held in tables

    2. Retrieval of this data must be possible

    using the following types of operationSelect, Join,Project

    3. A relationship between data must be

    represented explicitly in that data itself.

  • 7/29/2019 Databases Ys

    66/75

    Aims of Relational Database

    1. Performance

    2. The ability to distribute data.

    3. The ability to handle enormousquantity of data

  • 7/29/2019 Databases Ys

    67/75

    Distributed Processing

    It refers to an architecture in which adatabase resides on a different machine tothe user process accessing it.

    To put this in a different way,the front andback end processes are on differentmachines.Such a machine will obviouslynecessitate some form of communicationcapability between the machine and depends

    entirely on a complex logical and physicalseparation between the front and back endprocesses and processing

    Distributed database

  • 7/29/2019 Databases Ys

    68/75

    Distributed database

    A distributed data system is a collection of sites

    or connected by communication lineswhereby:

    1. Each participating node houses a relational

    database2. These databases are themselves fully

    functional within their own location.

    3. A logical global distributed database isdefined incorporating elements of each ofthe participating databases in order toevaluate a single occurrence of a database.

    Normalisation

  • 7/29/2019 Databases Ys

    69/75

    NormalisationIt is the processes of simplifying the relationshipbetween data elements in a record.Throughnormalization, a collection of data in a recordstructure is replaced by successive recordstructures that are simpler and more predictableand therefore more manageable.The reasons whyit is carried out are:

    1. To structure the data to maintain the data an itsrelationship.

    2. To permit simple retrieval of data in response toquery and report requests.

    3. To simplify the maintenance of the data throughupdated inventories and deletions.

    4. To reduce the need to restructure or reorganizedata when application requirements arise.

    Degree of Normalisation

  • 7/29/2019 Databases Ys

    70/75

    Degree of Normalisation1NF(First Normal Form)

    2NF(Second Normal Form)3NF(Third Normal Form)

    BCN(Boyce-codd Normal Form)

    4NF(Fourth Normal Form)5NF(Fifth or Projection-Join NormalForm)

    1NF(First Normal Form)

  • 7/29/2019 Databases Ys

    71/75

    1NF(First Normal Form)

    This is the lowest level of normalization.Arelation is said to be in 1NF if there will

    be no composite attributes,and everyattributes is single and describes oneproperty.

    2NF(Second Normal Form)

  • 7/29/2019 Databases Ys

    72/75

    2NF(Second Normal Form)A relation is said to be in 2NF if it is in 1NFand non-key attributes are functionally

    dependent on the key attribute(S).Further,ifthe key has more than one attribute then nonon key attributes should be functionallydependent upon a part of the key attributes.

    An attribute is a non-key if it is not part ofthe primary key.

    An attribute is functionally dependent on akey if the attribute contains only one value

    which depends on that key .For eg:theattribute SALARY contains only one valuewhich depends on the key NAME.

    3 ( hi d l )

  • 7/29/2019 Databases Ys

    73/75

    3NF(Third Normal Form)

    Data is in 3NF if and only if it is in 2NF and every non-key

    attribute is non-transitively dependent on the primary key.A3NF will be needed where all attributes in a relation tuple arenot functionally dependent ,then there will be unnecessaryduplication of data.The purpose of 3NF is to ensure that

    attributes directly belong to the entity.Transitivity is a mathematical principle that states

    If a relation is true between the first value and thesecond,and between the second and the third, then the

    relationship must also be true between the first and the third.Examples If AC

    If A=B and B=C,then A=C

    Boyce-cod Normal form

  • 7/29/2019 Databases Ys

    74/75

    Boyce cod Normal form

    When a relation has more than one possiblekey and the composite keys have a common

    attribute and if an attribute of a compositekey is dependent on an attribute of the othercomposite key,a BCNF is need.For example

    Professor(professor code,Dept,HOD,PercenttimeIt is assumed that

    A professor can work in more than one

    departmentThe percentage of time he spends in eachdepartment is given

    Each department has only one HOD

  • 7/29/2019 Databases Ys

    75/75

    Fourth and Fifth Normal form

    When attributes in a relation havemultivalued dependency, further

    normalization to 4NF and 5NF arerequired