kzt for dbc

Upload: kyaw-zin-thant

Post on 01-Mar-2018

222 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/25/2019 kzt for dbc

    1/31

    Data Analysis and Design

    Task 1

    1) Critically compare diferent data models such as hierarchical model,network model, relational model and diferent schemas such asconceptual schema, physical schema. (Main actors) (Model achin chinsimilarities , diferences, ad!antages, disad!antages)

    1(a) physical and logical !iew o" data

    #hysical !iew o" data

    The physical !iew with the actual, physical arrangement and location o" data

    in the direct access storage de!ices. Data$ase specialists use the physical

    !iew to make e%cient use o" storage and processing resources.

    &ogical !iew o" data

    The logical !iew o" a data$ase program represents data in a "ormat that is

    meaning"ul to a user and to the so"tware programs that process those data

    and identi"y the application program's logical !iews o" data within an o!erall

    logical data structure.

    ($) A$out the data$ase and ad!antages o" using data$ase

    A data$ase is a collection o" in"ormationthat is organied so that it can

    easily $e accessed, managed, and updated. A collection o" related data

    http://searchsqlserver.techtarget.com/definition/informationhttp://searchsqlserver.techtarget.com/definition/information
  • 7/25/2019 kzt for dbc

    2/31

    specially organied to $e retrie!ed uickly and normally structured and

    inde*ed "or user access and re!iew. Data$ases may e*ist in the "orm o"

    physical +les ("olders, documents, etc.) or "ormatted automated data

    processing system data +les.

    asically, the ad!antages o" data$ases are ..

    - Concurrent se

    - /tructured and Descri$ed Data

    - /eparation o" Data and Applications

    - Data 0ntegrity

    - Transactions

    - Data #ersistence

    - Data iews

    The data$ase can reduce the data redundancy, updating errors and

    increased consistency and data entry, storage, and retrie!al costs.

    0mpro!ed data access to users through use o" hosts , uery languages anddata security.

    (c) 0n which situations we need data$ase system "or applications2

    A data$ase is a computer program whose primary purpose is entering andretrie!ing in"ormation "rom a computeried data$ase.Data$ase most use"ul in many large hotels .They used "or their customername and how much stay in their hotel .These data stored in data$ase.Most companies are use data$ase .3hy they use data$ase2 .They useddata$ase "or their customers $ank accounts .Their names ,0# address , howmuch deposited money and how much trans"erred money are stored indata$ases.&i$raries are used data$ase . They used their students data and new

    another customers. /tudent names , 0# address , $ook names .These dataare stored in data$ase. 3hy they are used data$ase 2. They used data$asesal!e their times , money , li"e . /o, they are used data$ase .

    http://www.gitta.info/IntroToDBS/en/html/DBApproaChar_mehrfachn.htmlhttp://www.gitta.info/IntroToDBS/en/html/DBApproaChar_struktDaten.htmlhttp://www.gitta.info/IntroToDBS/en/html/DBApproaChar_trennDataApp.htmlhttp://www.gitta.info/IntroToDBS/en/html/DBApproaChar_dataint.htmlhttp://www.gitta.info/IntroToDBS/en/html/DBApproaChar_transakt.htmlhttp://www.gitta.info/IntroToDBS/en/html/DBApproaChar_datapersis.htmlhttp://www.gitta.info/IntroToDBS/en/html/DBApproaChar_datensichten.htmlhttps://en.wikipedia.org/wiki/Databasehttp://www.gitta.info/IntroToDBS/en/html/DBApproaChar_mehrfachn.htmlhttp://www.gitta.info/IntroToDBS/en/html/DBApproaChar_struktDaten.htmlhttp://www.gitta.info/IntroToDBS/en/html/DBApproaChar_trennDataApp.htmlhttp://www.gitta.info/IntroToDBS/en/html/DBApproaChar_dataint.htmlhttp://www.gitta.info/IntroToDBS/en/html/DBApproaChar_transakt.htmlhttp://www.gitta.info/IntroToDBS/en/html/DBApproaChar_datapersis.htmlhttp://www.gitta.info/IntroToDBS/en/html/DBApproaChar_datensichten.htmlhttps://en.wikipedia.org/wiki/Database
  • 7/25/2019 kzt for dbc

    3/31

    (d) the role o" data$ase administrator.

    A data$ase administrator (DA) is responsi$le "or the per"ormance, integrityand security o" a data$ase.

    4 data remains consistent across the data$ase

    4 data is clearly de+ned

    4 users access data concurrently, in a "orm that suits their needs

    4 there is pro!ision "or data security and reco!ery control

    (e) the key organiational issues o" integrity , reco!ery, security andconcurrency

    0ntegrity

    CentraliedcontrolcanalsoensurethatadeuatechecksareincorporatedintheDM/topro!idedataintegrity.Dataintegritymeansthatthedatacontainedinthedata$aseis$othaccurateandconsistent.

    /ecurity

    Dataiso"!italimportancetoanorganiationandmay$econ+dential./uch

    con+dentialmustnot$eaccessed$yunauthoriedpersons.Diferentle!elso"secur

    itycould$eimplemented"or!arioustypeso"data and operations.

    Con5ict 6esolution

    A data$ase chooses the$est+lestructureandaccessmethodtogetoptimalper"ormance"ortheresponsecriticalapplications,whilepermittinglesscriticalapplicationstocontinuetousethedata$ase,al$eitwitharelati!elyslowerresponse.

    Data 0ndependence

  • 7/25/2019 kzt for dbc

    4/31

    Dataindependenceisusuallyconsidered"romtwopointso"!iew7physicaldataindependenceandlogicaldataindependence..

    #hysical data

    independenceallowschangesinthephysicalstoragede!icesororganiationo"the+lesto$emadewithoutreuiringchangesintheconceptual!ieworanyo"thee*ternal!iewsandhenceintheapplicationprogramsusingthedata$ase.

    &ogical dataindependenceimpliesthatapplicationprogramsneednot$echangedi"

    ieldsareaddedtoane*istingrecord8nordotheyha!eto$echangedi%eldsnotused$yapplicationsprogramsaredeleted. 9ou may ha!e e*perienced somethinglike the "ollowing e*ample7

    0magine there are two people in your team or o%ce, $oth o" whom are greatat managing $udgets. They are $oth accurate, detail:oriented and deli!er theresults needed. ;owe!er, one o" them is a real people person. Theirinterpersonal and communication skills are "antastic and, as a result o" this,they ha!e no pro$lem getting the in"ormation they reuire uickly "romcolleagues at any le!el. The other person does not ha!e this skill and o"tenencounters con5ict "rom colleagues, perhaps "or many diferent reasons.

    3hich o" these people do you think needs personal de!elopment training2

    As you can see "rom the e*ample, $oth can do their

  • 7/25/2019 kzt for dbc

    5/31

    0n data$ases using the simple reco!ery model, you may restore "ull ordiferential $ackups only. 0t is not possi$le to restore such a data$ase to agi!en point in time, you may only restore it to the e*act time when a "ull ordiferential $ackup occurred. There"ore, you will automatically lose any datamodi+cations made $etween the time o" the most recent "ull=diferential

    $ackup and the time o" the "ailure.

    /ecurity

    Data$ase security co!ers and en"orces security on all aspects andcomponents o" data$ases. This includes7

    - Data stored in data$ase

    - Data$ase ser!er

    - Data$ase management system (DM/)

    - >ther data$ase work5ow applicationsData$ase security is generally planned, implemented and maintained $y adata$ase administrator and or other in"ormation security pro"essional.

    /ome o" the ways data$ase security is analyed and implemented include7

    - 6estricting unauthoried access and use $y implementing strong andmulti"actor access and data management controls.

    - &oad=stress testing and capacity testing o" a data$ase to ensure it doesnot crash in a distri$uted denial o" ser!ice attack or user o!erload.

    - #hysical security o" the data$ase ser!er and $ackup euipment "romthe"t and natural disasters.

    Concurrency

    Concurrency can $e de+ned as the a$ility "or multiple processes to access orchange shared data at the same time.Data$ase concurrency controls ensurethat transactions occur in an ordered "ashion. The main

  • 7/25/2019 kzt for dbc

    6/31

    ? Critically discuss the $ene+ts and limitations o" diferentdata$ase technologies&arge $usiness organiations make use o" Data warehouses with datamining techniues "or $usiness decision making. @*plain what is a datawarehouse and how data mining is used in the decision making

    process

    (1) the "eatures o" DM/

    Conceptual data$ase design

    : a model o" in"ormation used in an enterprise. : independent o" all physical considerations. : identi+cation o" entities, relationships, and attri$utes.

    : conceptual data$ase are independent o" DM/ : they are "ree "rom the technical details such as the +eld sie, +eldtypes, constrains and so on : allows "or easy comunication $etween end:users and de!elopers. : has a clear method to con!er "rom high:le!el model to relationalmodel. : conceptual schema is a permanent description o" the data$asereuirements.

    #ri!ate /cope

    #ri!ate !aria$les and pri!ate methods are only accessi$le to the o$

  • 7/25/2019 kzt for dbc

    7/31

    >nce you think youEre syncEd then you need to per"orm !eri+cation to ensure

    that you know where your starting point is.

    Code #romotion

    6e"reshes are usually at the start a de!elopment cycle, which means thatyou will pro$a$ly run (test, pro!e, etc.) the ne*t releases code $ase (scripts).

    0" you are dealing with A, the Turn Center will actually do the turn !ia a TC3.

    Code turns should A&3A9/ $e !eri+ed, regardless o" who does them.

    Data$ase se F This is why the data$ase e*istsG utiliation $y an end:use

    process. A and Test ha!e the same end:use processes8

  • 7/25/2019 kzt for dbc

    8/31

    &ogical data$ase design

    - $ased on a speci+c data model (e.g. relational)

    - independent o" a particular DM/ and other physical considerations- logical structure o" the data$ase.

    #hysical data$ase design.

    - Decide how the logical structure is to $e physically implemented in thetarget DM/.

    Decisions on- 0nde*- DM/- Application #rograms- ;ardware

    ($) the ad!antages and disad!antages o" DM/

    Ad!antages o" DM/

    /hared Data

    A data$ase allows the sharing o" data under its control $y any num$er o"application programs or users.

    0ntegrity

    Centralied control can also ensure that adeuate checks are incorporated inthe DM/ to pro!ide data integrity .Data integrity means that the datacontained in the data$ase is $oth accurate and consistent.

  • 7/25/2019 kzt for dbc

    9/31

    /ecurity

    Data is o" !ital importance to an organiation and may $e con+dential . /uch

    con+dential must not $e accessed $y unauthoried persons. Diferent le!els

    o" security could $e implemented "or !arious types o" data and operations.

    Con5ict 6esolution

    A data$ase chooses the $est +le structure and access method to get optimalper"ormance "or the responsecritical applications, while permitting less critical applications to continue touse the data$ase, al$eit with a relati!ely slower response.

    Data 0ndependence

    Data independence is usually considered "rom two points o" !iew 7 physicaldata independence and logical data independence..

    #hysical data independence allows changes in the physical storage de!icesor organiation o" the +les to $e made without reuiring changes in theconceptual !iew or any o" the e*ternal !iews and hence in the application

    programs using the data$ase.

    &ogical data independence implies that application programs need not $echanged i"ields are added to an e*isting record 8 nor do they ha!e to $e changed i"

    +elds not used $y applications programs are deleted. To address your

    uestion, impro!ements in speed and per"ormance o" your &AH and 3AH

    depend on se!eral "actors, $udget and technology. 3ith the &AH, 0 am going

    to recommend a "ew general guidelines and $est practices on design to

    ensure relia$le per"ormance. or the 3AH, there are se!eral "actors to

    consider that are more cost prohi$iti!e. Decide what works $est "or your

    enterprise and en!ironment.

    To address potential per"ormance issues on the &AH, you want to identi"y and

    isolate any $ottlenecks due to technology. >n &AHs, you are a$le to achie!e

    $etter per"ormance results with high speed, low cost technologies like

  • 7/25/2019 kzt for dbc

    10/31

    @thernet. @nsure that all o" your ser!ers in the Citri* Metarame "arm are

    capa$le o" at least 1M$ps at "ull duple*. >"tentimes, 0 recommend that the

    switches $e hard wired "or this con+guration (or higher i" applica$le) to

    reduce any potential pro$lems with auto negotiation. A good &AH design also

    ensures that the right &AH and /panning Tree implementations are in place

    to reduce multicast and $roadcast congestion and $ridging loops. 0" not

    currently implemented, ensure that the ser!ers are on a managed switch

    that supports multiple &AH con+gurations and /panning Tree. y

    implementing managed switches in the en!ironment, the switches will $e

    a$le to assist you with control o!er the ser!er ports and reduce collisions. 0n

    summary, ensure that you ha!e managed switches on the network that can

    control &AHs and $ridging loops. Also ensure the ser!er switch ports are set

    to the right speed and duple* settings. These are the two ma

  • 7/25/2019 kzt for dbc

    11/31

    ackup and reco!ery operations are "airly comple* in a DM/en!ironment, and this is e*acer$ated in a concurrent multi userData$ase system. 3AH issues, Citri* Metarame clients are a good start.Citri* Metarame clients are uite efecti!e when circuits are already hea!ilycongested and you need to reduce the amount o" tra%c that the users are

    trans"erring o!er the 3AH. n"ortunately, Citri* tends to ha!e a per"ormancehit when it comes to the end user e*perience. This is due to the "act thatdepending on the Citri* Metarame deployment you ha!e implemented, theclient when launched will open a single TC# session. 3ith this single TC#session, the screen updates and re"reshes are sent to the client's machine atthe remote location. 3hile this consumes less $andwidth, any sort o" delayor dropped packet causes the end:user response times to degradesigni+cantly. 0" there are any sources o" delay within the network and apacket is lost, the TC# window "or the single:session client will dropsigni+cantly. To compensate "or this ensure that the links are not congestedand special treatment (o/) policies are gi!en to Citri* clients to ensure

    packets are gi!en the $est per"ormance. ;owe!er, you must also $e awarethat $y doing so, you efecti!ely compromise the per"ormance o" otherapplications on the network. There are tools that allow you to trou$leshootand analye the per"ormance o" 3AH:deployed applications. 0" you would likemore in"ormation on these tools, please let me know and 0 will happily supplythat in"ormation.

    Monitor dash$oards I #ro!ides Monitoring, @nerygy3ise and 0dentity

    dash$oards to monitor the status and the per"ormance o" network.

    - Monitoring tools I #ro!ides tools such as ault Monitor, @!ent Monitor,

    Mini6M>H and Topology /er!ices to !iew the in"ormation on network "aults,

    e!ents, links and ports in the network and per"orm remote monitoring

    "unctions.

    - Diagnostic tools I #ro!ides "ramework such as @m$edded @!ent

    Manager (@@M) and Jeneric >nline Diagnostics (J>&D) "or diagnostic

    operations across Cisco plat"orms running Cisco 0>/ /o"tware.

    - Trou$leshooting tools I #ro!ides trou$leshooting work5ows, Hetshow

    and 6:lite to trou$leshoot the network connecti!ity, diagnose de!ice

    pro$lems, identi"y endhost pro$lems, and !eri"y end:to:end connecti!ity o"

    6 con+gured de!ices.

    - ault /ettings I ;elps you to set up the "ault polling parameters, "ault

    threshold settings, /HM# traps "orwarding and recei!ing, and allows you to

    !iew the "ault de!ice details.

  • 7/25/2019 kzt for dbc

    12/31

    - #er"ormance /ettings I ;elps you to manage pollers and templates,

    ena$le Automonitoring "unctionality, and manage 0#/&A collectors and

    de!ices.

    - Threshold /ettings I ;elps you to manage Trendwatch, set up "ault and

    per"ormance threshold settings

    3. Analyze different approaches to database design such as top-down approach or bottom-

    up approach.

    There are two basic strategies to dealing with information processing and software design: the

    top-down and the bottom up approaches. These two paradigms are often used at the start of

    development to create domain models and plot the path of work to be done on a project. hilethey are often used concurrently! there are specific drawbacks and benefits to each! and balancing

    this is key to building a successful piece of software.

    Top-Down

    The top-down approach! also known as step-wise design! essentially breaks a system or model

    down into component sub-systems! each of which may further broken down further. "owever! nofirst-level system are defined # you won$t describe a for loop! or define the attributes of an objectin the top-down approach. %ystems end up as a series of &black bo'es$( components that have

    specific inputs and outputs! but no definite internal structure.

    Why Top-Down?

    This approach lends itself to most projects! and doesn$t re)uire a specific kind of team or

    breakdown

    *t allows large teams to split themselves amongst subsystems

    +ue to definite inputs and outputs of each subsystem! combining them is simplified

    *t encourages object-oriented programming ,/ via encapsulation

    *t is still very successful for functional programming

  • 7/25/2019 kzt for dbc

    13/31

    *t works very well for small projects! by laying out specific &tasks$ to be done.

    0asy to maintain! because of this subsystem partitioning

    Why Not Top-Down?

    *t is difficult to guarantee that the initial design ade)uately models the desired system

    *t is tougher to do testing! as a large portion of the design must be done first

    n a large projects! reduntant code may become an issue

    Bottom-Up

    *f you know what 1egosare! you know what bottom-up design is. *t consists of defining and

    coding the very basic! definite parts of the system to be designed! then linking these parts

    together to form the whole.

    Why Bottom-Up?

    This approach allows teams to code functioning sub-systems )uickly

    Testing can be done early and often! as first-level systems are defined first

    *t encourages and leads to reusable code

    re-e'isting code is simpler to incorporate and test

    Why Not Bottom-Up?

    ithout some forethought! modules may be difficult to link together

    The resulting system may be tangled and difficult to maintain

    ithout an overarching design! it can be difficult to define specific functionality for each

    module

    Example :These are two design approaches, which can be explained as:

    You can imagine a tree like structure , in which when you

    are following top-down appoarch you move from root node to

    leaf node and when you follow bottom-up apprach you follow

    leaf node to root node.

    Top-down approach:

    http://lego.wikia.com/wiki/LEGO_Wikihttp://lego.wikia.com/wiki/LEGO_Wiki
  • 7/25/2019 kzt for dbc

    14/31

    In this an overview of the system is first formulated,

    specifying but not detailing any first-level subsystems.

    ach subsystem is then refined in yet greater detail,

    sometimes in many additional subsystem levels, until the

    entire specification is reduced to base elements.

    !ottom-up approach:

    In this approach the individual base elements of the system

    are first specified in great detail. These elements are

    then linked together to form larger subsystems, which then

    in turn are linked, sometimes in many levels, until a

    complete top-level system is formed.

    Task 2(LO 2: AC 2.1,2.2,2.3 and M1,M2)

    2 Analyse and write a re)uirement specification for your system applying the any factfinding methods

    Perform an analysis of the problem using object-oriented techniquesAn e'ternal view of the enterprise model of the student registration including student

    records! department and staff information! course re)uirements! and class sche

    dules will be developed using nified 4odeling 1anguage ,41/. This %ystem

    5e)uirement %pecifications documents will form part of the documentation for the project.

    %ome desired features of the new system include:

    The ability to search6view course offerings on-line

    rovide transcripts on-line

    0valuate prere)uisites for courses against student records

    *nform students of registration stops and provide

    ability to resolve and registration conflict,s/

    Allow students to fill out applications for graduation and plans of study.

    Scope and Limitations

    Analysis methodology will involve business analysis! re)u

    irement analysis! data analysis! process analysis! ,web/

    and application architecture:

  • 7/25/2019 kzt for dbc

    15/31

    7usiness analysis # %tate the business rules! business system interfaces! business function!

    business ownership! sponsorship and associated project budget re)uirement

    5e)uirement analysis # %ystem *6 description! user re)uirement definition! functional and

    security re)uirement

    +ata analysis # *nvolve data collection process! datavalidation! data storage! manipulation

    and retrieval

    rocess analysis # +ata6process flow analysis! process decomposition and system interfaces

    Application architecture # Analyze

    application information structure!

    usability! user interface design!

    interaction and application implementation

    ? +esign a relational database system to meet a given re)uirement +raw 0ntity 5elationship +iagram ,05+/ identifying the main 0ntities and 5elationships.

    o 0'plain entity types and 8ey attributes and their types in a data model.

    o 1ist the rimary key and foreign key,s/ for each entity.

  • 7/25/2019 kzt for dbc

    16/31

  • 7/25/2019 kzt for dbc

    17/31

    entity types

    Strong Entity: 0ntities having its own attribute as primary keys are called strong entity.

    9or e'ample! %T+0T has %T+0T;*+ as primary key. "ence it is a strong entity.

    Weak Entity: 0ntities which cannot form their own attribute as primary key are known

    weak entities. These entities will derive their primary keys from the combination of its

    attribute and primary key from its mapping entity.

  • 7/25/2019 kzt for dbc

    18/31

    Composite Entity: 0ntities participating in the many to many relationships are called

    composite entity. *n this case! apart from two entities that are part of relation! we will one

    more hidden entity in the relation. e will be creating a new entity with the relation! andcreate a primary key by using the primary keys of other two entities.

  • 7/25/2019 kzt for dbc

    19/31

    8ey attributes

    Simpe !ttri"ute

    These kinds of attributes have values which cannot be divided further. 9or e'ample!

    %T+0T;*+ attribute which cannot be divided further. assport umber is uni)uevalue and it cannot be divided.

    Composite !ttri"ute

    This kind of attribute can be divided further to more than one simple attribute. 9or

    e'ample! address of a person. "ere address can be further divided as +oor=! street! city!state and pin which are simple attributes.

    Derive# !ttri"ute

    +erived attributes are the one whose value can be obtained from other attributes of

    entities in the database.9or e'ample! Age of a person can be obtained from date of birth

    and current date. Average salary! annual salary! total marks of a student etc are few

    e'amples of derived attribute.

    Store# !ttri"ute

    The attribute which gives the value to get the derived attribute are called %tored Attribute.

    *n e'ample above! age is derived using +ate of 7irth. "ence +ate of 7irth is a stored

    attribute.

    Singe $aue# !ttri"ute

    These attributes will have only one value. 9or e'ample! 041>00;*+! passport=!driving license=! %% etc have only single value for a person.

    %uti-$aue# !ttri"ute

    These attribute can have more than one value at any point of time. 4anager can have

    more than one employee working for him! a person can have more than one emailaddress! and more than one house etc is the e'amples.

    Simpe Singe $aue# !ttri"ute

  • 7/25/2019 kzt for dbc

    20/31

    This is the combination of above four types of attributes. An attribute can have single

    value at any point of time! which cannot be divided further. 9or e'ample!

    041>00;*+ # it is single value as well as it cannot be divided further.

    Simpe %uti-$aue# !ttri"ute

    hone number of a person! which is simple as well as he can have multiple phone

    numbers is an e'ample of this attribute.

    Composite Singe $aue# !ttri"ute

    +ate of 7irth can be a composite single valued attribute. Any person can have only one

    +7 and it can be further divided into date! month and year attributes.

    Composite %uti-$aue# !ttri"ute

    %hop address which is located two different locations can be considered as e'ample ofthis attribute.

    Descriptive !ttri"ute

    Attributes of the relationship is called descriptive attribute. 9or e'ample! employee works

    for department. "ere &works for$ is the relation between employee and department

    entities. The relation &works for$ can have attribute +AT0;9;?* which is adescriptive attribute.

    #rimary key

    Aprimary keyis a column or group of columns that uni)uely identify a row. 0very table should

    have a primary key. And a table cannot have more than one primary key. The 5*4A5>

    80>

    characteristic can be specified as part of a column definition! as in the first column of theCountrytable! or it can be specified as a separate clause of the

  • 7/25/2019 kzt for dbc

    21/31

    oreign key

    K Aforeign keyis a column or set of columns in one table whose values musthave matching

    values in the primary key of another ,or the same/ table. A foreign key is said to referenceits

    primary key. 9oreign keys are a mechanism for maintaining data integrity. *n theJobtable! for

    e'ample! any country listed in thejob_countrycolumn must also e'ist in the Countrytable. 7y

    stating that thejob_countrycolumn of theJobtable is a foreign key that references the

    countrycolumn of the Countrytable! you are guaranteeing this! because *nter7ase will return an

    error if a value is entered thejob_countrycolumn that does not have a matching entry in the

    countrycolumn of the Countrytable.

    3 7uild a relational database system based on a prepared design using any using appropriate

    5+74% software! e.g. 4icrosoft %@1 %erver! racle etc. 4ake sure you follow all the

    necessary steps in building the database. *n building the relational database! you are e'pectedto include the following:

    relations! fields

    data types

    referential constraints

    views! inde'es

    stored procedures! triggers etc

    Apply a range of database tools and techni)ues to enhance the user interface

    +raw a

  • 7/25/2019 kzt for dbc

    22/31

    A data$ase is a organised collection o" inter:related data that is structured

    into ta$les, records, +elds, ueries, reports, !iews and other o$

  • 7/25/2019 kzt for dbc

    23/31

  • 7/25/2019 kzt for dbc

    24/31

    Task 3(LO 3: AC 3.1,3.2,3.3 and D1)

    2/ *mplement a )uery language into the relational database system

    btain from the sers some representative en)uiries for the +atabase. 9ormulate the

    %@1 )ueries to produce some reports. 4ake sure that you have enough data in your

    database to show reports.

    #ro$lems o" Concurrent transactions

    &ost updates (#ro$lems)

    Time T1 T? al*

    T1 egin:transaction

    T? egin:transaction 6ead ($al*)

    TL 6ead ($al*) al*$al*NO

    TP al*$al*:? 3rite($al*) 1P

    TO 3rite($al*) commit Q

    TR ommit Q

    #re!enting &ost update pro$lem

  • 7/25/2019 kzt for dbc

    25/31

    Time T1 T? $la*

    T1 egin:transaction ?

    T? egin:tansaction 3rite:lock($al*) ?

    TL 3rite:lock($al*) read($al*) ?

    TP 3A0T al*$al*N1 ?

    TO 3A0T 3rite($al*) L

    TR 3A0T Commit=unlock($al*) L

    TQ 6ead($al*) L

    TB al*$al*:O L

    T 3rite($al*) ?O

    T1 Commit=unlock($al*) ?O

    Dirty 6ead pro$lem(ncommited Dependency >ccurs when one transaction

    can see intermediate results o" other transaction $e"ore it has commited)

    Time TL TP $al*

    T1 egin:transaction 1O

    T? 6ead($al*) 1O

    TL al*$la*NL 1O

    TP egin:transaction 3rite($al*) 1B

    TO 6ead($al*).. 1B

    TR la*$al*:? roll$ack 1O

  • 7/25/2019 kzt for dbc

    26/31

    TQ 3rite($al*) 1R

    TB commit 1R

    #re!enting Dirty 6ead with ?#hase protocol

    Time TL TP $al*

    T1 egin:transaction 1

    T? 3rite:lock($al*) 1

    TL 6ead($al*) 1

    TP egin:transaction al*$al*1 1

    TO 3rite:lock($al*) 3rite($al*) ?

    TR 3A0T 6oll$ack=unlock($al*) 1

    TQ 6ead($al*) 1

    TB al*$al*:1 1

    T 3rite($al*)

  • 7/25/2019 kzt for dbc

    27/31

    T1 Commit=unlock$al*)

    nrepeata$le read pro$lems (0nconsistent analysis F>ccurs when transaction

    reads se!eral $ut ?ndtransaction updates same o" them during e*ecution o"

    +rst)

    Time

    TO TR $la* $aly $al sum

    T1 egin:transaction ? RO

    T?egin:transaction

    /um ? R O

    TL 6ead($al*) 6ead($al*) ? R O

    TP al*$al*:? /umsumN$al* ? R O ?

    TO 3rite($al*) 6ead($aly) 1B R O ?

    TR 6ead($al) /umsumN$aly 1B R O 1R

    TQ al$alN1 1B R O 1R

    TB 3rite($al) 1B R O 1R

    T commit 6ead($al) 1B R RO 1R

    T1 /umsumN$al 1B R RO ??O

    T11 commit 1B R RO ??O

  • 7/25/2019 kzt for dbc

    28/31

    #re!enting nrepeata$le 6ead with ?#hase locking (?#l)

    Time

    TO TR $al*

    $aly $al

    sum

    T1 egin:transaction 1

    1 O

    T? egin:transaction /um 1

    1 O

    TL 3rite:lock($al*) 1

    1 O

    TP 6ead($al*) 6ead:lock($al*) 1

    1 O

    TO al*$al*:1O 3A0T 1

    1 O

    TR 3rite($al*) 3A0T BO 1 O

    TQ 3rite:lock($al) 3A0T BO 1 O

    TB 6ead($al) 3A0T BO 1 O

    T al$alN1 3A0T BO 1 O

    T1 3rite ($al) 3A0T BO 1 RO

    T11 Commit=unock($al*,$aly,$al)

    3A0T BO 1 RO

    T1? 6ead($al*) BO 1 RO

  • 7/25/2019 kzt for dbc

    29/31

    T1L /umsumN$al* BO 1 RO BO

    T1P 6ead:lock($aly) BO 1 RO BO

    T1O 6ead($aly) BO 1 RO BO

    T1R /umsumN$aly BO 1 RO 1BO

    T1Q 6ead:lock ($al) BO 1 RO 1BO

    T1B 6ead($al) BO 1 RO 1BO

    T1 /umsumN$al BO 1 RO ?O

    T?Commit=unlock($al*,$aly,$al)

    BO 1

    RO ?O

    Ta$le Hame7 ooking

    0@&D HAM@ DATA T9#@ C>H/T6A0HT D@/C60#T0>H0D !archar(L) #rimary key

    #0D !archar(L) Hot nullus0D !archar(L) Hot null

    Ta$le Hame7 us

  • 7/25/2019 kzt for dbc

    30/31

    0@&D HAM@ DATA T9#@ C>H/T6A0HT D@/C60#T0>Hus0D !archar(L) #rimary keyusHAM@ !archar(L) Hot nullusType !archar(L) Hot null

    Ta$le Hame7 usS /tatus

    0@&D HAM@ DATA T9#@ C>H/T6A0HT D@/C60#T0>H/0D !archar(L) #rimary keyus0D !archar(L) oreign key/ource !archar(L) Hot null

    Destination !archar(L) Hot nullTotalseats !archar(L) Hot null

    Ta$le Hame7 #assengers

    0@&D HAM@ DATA T9#@ C>H/T6A0HT D@/C60#T0>H#0D !archar(L) #rimary key#HAM@ !archar(L) Hot null#;>H@ !archar(L) Hot nullADD6@// !archar(L) Hot null

    H6C !archar(L) Hot null

    Ta$le Hame7Ticket

    0@&D HAM@ DATA T9#@ C>H/T6A0HT D@/C60#T0>HT0D !archar(L) #rimary key#0D !archar(L) oreign key

  • 7/25/2019 kzt for dbc

    31/31

    #HAM@ !archar(L) Hot null#rice int Hot nullDepTime datetime Hot null/eatHo int Hot null