Sie sind auf Seite 1von 29

History The first general-purpose DBMS, designed by Charles Bachman at General Electric in the early !

"#s, $as called the %ntegrated Data Store& %t formed the basis for the net$or' data model, $hich $as standardi(ed by the Conference on Data Systems )anguages *C+D,S-). and strongly influenced database systems through the !"#s& Bachman $as the first recipient of ,CM/s Turing ,$ard *the computer science e0ui1alent of a 2obel 3ri(e. for $or' in the database area4 he recei1ed the a$ard in !56& %n the late !"#s, %BM de1eloped the %nformation Management System *%MS. DBMS, used e1en today in many ma7or installations& %MS formed the basis for an alternati1e data representation frame$or' called the hierarchical data model& The S,B8E system for ma'ing airline reser1ations $as 7ointly de1eloped by ,merican ,irlines and %BM around the same time, and it allo$ed se1eral people to access the same data through a computer net$or'& %n !5#, Edgar Codd, at %BM/s San 9ose 8esearch )aboratory, proposed a ne$ data representation frame$or' called the relational data model& This pro1ed to be a $atershed in the de1elopment of database systems: %t spar'ed the rapid de1elopment of se1eral DBMSs based on the relational model, along $ith a rich body of theoretical results that placed the field on a firm foundation& Codd $on the !; Turing ,$ard for his seminal $or'& %n the !;#s, the relational model consolidated its position as the dominant DBMS paradigm, and database systems continued to gain $idespread use& ,d1antages of DBMS & Data %ndependence: ,pplication programs should not, ideally, be e<posed to details of data representation and storage, The DBMS pro1ides an abstract 1ie$ of the data that hides such details& =& Efficient Data ,ccess: , DBMS utili(es a 1ariety of sophisticated techni0ues to store and retrie1e data efficiently& This feature is especially important if the data is stored on e<ternal storage de1ices& 6& Data %ntegrity and Security: %f data is al$ays accessed through the DBMS, the DBMS can enforce integrity constraints, it can enforce access controls that go1ern $hat data is 1isible to different classes of users& >& Data ,dministration: ?hen se1eral users share the data, centrali(ing the administration of data can offer significant impro1ements& @& Concurrent ,ccess and Crash 8eco1ery: , DBMS schedules concurrent accesses to the data in such a manner that users can thin' of the data as being accessed by only one user at a time& Aurther, the DBMS protects users from the effects of system failures& "& 8educed ,pplication De1elopment Time: Clearly, the DBMS supports important functions that are common to many applications accessing data in the DBMS& Databases are speciali(ed structures that allo$ computer-based systems to store, manage, and retrie1e data 1ery 0uic'ly& Data are ra$ facts& The $ord ra$ indicates that the facts ha1e not yet been processed to re1eal their meaning& %nformation is the result of processing ra$ data to re1eal its meaning& Data processing can be as simple as organi(ing data to re1eal patterns or as comple< as ma'ing forecasts or dra$ing inferences using statistical modeling&

%n this Binformation age,C production of accurate, rele1ant, and timely information is the 'ey to good decision ma'ing& %n turn, good decision ma'ing is the 'ey to business sur1i1al in a global mar'et& ?e are no$ said to be entering the B'no$ledge age&CData are the foundation of information, $hich is the bedroc' of 'no$ledgeDthat is, the body of information and facts about a specific sub7ect& Eno$ledge implies familiarity, a$areness, and understanding of information as it applies to an en1ironment& , 'ey characteristic of 'no$ledge is that Bne$C 'no$ledge can be deri1ed from BoldC 'no$ledge& )etFs summari(e some 'ey points: Data constitute the building bloc's of information& %nformation is produced by processing data& %nformation is used to re1eal the meaning of data& ,ccurate, rele1ant, and timely information is the 'ey to good decision ma'ing& Good decision ma'ing is the 'ey to organi(ational sur1i1al in a global en1ironment& Data management is a discipline that focuses on the proper generation, storage, and retrie1al of data& Gi1en the crucial role that data play, it should not surprise you that data management is a core acti1ity for any business, go1ernment agency, ser1ice organi(ation, or charity& Database is a shared, integrated computer structure that stores a collection of end-user data and metadata& End-user data are ra$ facts of interest to the end user& Metadata, or data about data, through $hich the end-user data are integrated and managed&

Database management system *DBMS. is a collection of programs that manages the database structure and controls access to the data stored in the database& Types of Databases number of users o single-user database supports only one user at a time& , single-user database that runs on a personal computer is called a des'top database

multiuser database supports multiple users at the same time multiuser database supports a relati1ely small number of users *usually fe$er than @#. or a specific department $ithin an organi(ation, it is called $or'group database used by the entire organi(ation and supports many users *more than @#, usually hundreds. across many departments, the database is 'no$n as an enterprise database

)ocation o a database that supports data located at a single site is called a centrali(ed database

, database that supports data distributed across se1eral different sites is called a distributed database

ho$ they $ill be used and on the time sensiti1ity of the information gathered from them o , database that is designed primarily to support a companyFs day-to-day operations is classified as an operational database*sometimes referred to as a transactional or production database. Data $arehouse focuses primarily on storing data used to generate information re0uired to ma'e tactical or strategic decisions& Such decisions typically re0uire e<tensi1e Bdata massagingC *data manipulation. to e<tract information to formulate pricing decisions, sales forecasts, mar'et positioning, and so on

the degree to $hich the data are structured o o Gnstructured data are data that e<ist in their original *ra$. state, that is, in the format in $hich they $ere collected Structured data are the result of ta'ing unstructured data and formatting *structuring. such data to facilitate storage, use, and the generation of information& Semistructured data are data that ha1e already been processed to some e<tent& Aor e<ample, if you loo' at a typical ?eb page, the data are presented to you in a prearranged format to con1ey some information&

E<tensible Mar'up )anguage *HM). is a special language used to represent and manipulate data elements in a te<tual format& ,n HM) database supports the storage and management of semistructured HM) data&

Database design refers to the acti1ities that focus on the design of the database structure that $ill be used to store and manage end-user data& , database that meets all user re0uirements does not 7ust happen4 its structure must be designed carefully&

Manual Aile Systems such systems $ere often manual, paper-and-pencil systems& The papers $ithin these systems $ere organi(ed in order to facilitate the e<pected use of the data& Typically, this $as accomplished through a system of file folders and filing cabinets& ,s long as a data collection $as relati1ely small and an organi(ationFs business users had fe$ reporting re0uirements, the manual system ser1ed its role $ell as a data repository&

Computeri(ed Aile Systems %nitially, the computer files $ithin the file system $ere similar to the manual files& ?hen business users $anted data from the computeri(ed file, they sent re0uests for the data to the D3 specialist& Aor each re0uest, the D3 specialist had to create programs to retrie1e the data from the file, manipulate it in $hate1er manner the user had re0uested, and present it as a printed report& Data processing *D3.

specialist $as hired to create a computer-based system that $ould trac' data and produce re0uired reports&

Basic Aile Terminology Data - B8a$Cfacts, such as a telephone number, a birth date, a customer name, and a year-to-date*-TD. sales 1alue& Data ha1e little meaning unless they ha1e been organi(ed in some logical manner& Aield I , character or group of characters *alphabetic or numeric. that has a specific meaning& , field is used to define and store data& 8ecord I , logically connected set of one or more fields that describes a person, place, or thing& Aor e<ample, the fields that constitute a record for a customer might consist of the customerFs name, address, phone number, date of birth, credit limit, and unpaid balance& Aile I , collection of related records&Aor e<ample, a file might contain data about the students currently enrolled at Gigantic Gni1ersity

38+B)EMS ?%TH A%)E S-STEM D,T, 38+CESS%2G Lengthy development times&The first and most glaring problem $ith the file system approach is that e1en the simplest data-retrie1al tas' re0uires e<tensi1e programming&?ith the older file systems, programmers had to specify $hat must be done and ho$ it $as to be done& Difficulty ofgetting quick answers&The need to $rite programs to produce e1en the simplest reports ma'es ad hoc 0ueries impossible& Complex system administration& System administration becomes more difficult as the number of files in the system e<pands& Lack of security and limited data sharing & ,nother fault of a file system data repository is a lac' of security and limited data sharing& Data sharing and security are closely related& Sharing data among multiple geographically dispersed users introduces a lot of security ris's& Extensive programming. Ma'ing changes to an e<isting file structure can be difficult in a file system en1ironment&

Structural and Data Dependence , file system e<hibits structural dependence, $hich means that access to a file is dependent on its structure& structural independence e<ists $hen it is possible to ma'e changes in the file structure $ithout affecting the application programFs ability to access the data& ?hen all data access programs are sub7ect to change $hen any of the fileFs data storage characteristics change *that is, changing the data type., the file system is said to e<hibit data dependence. data independence e<ists $hen it is possible to ma'e changes in the data storage characteristics $ithout affecting the application programFs ability to access the data&

The practical significance of data dependence is the difference bet$een the logical data format *ho$ the human being 1ie$s the data. and the physical data format*ho$ the computer must $or' $ith the data.& ,ny program that accesses a file systemFs file must tell the computer not only $hat to do but also ho$ to do it&

Data redundancy e<ists $hen the same data are stored unnecessarily at different places&Gncontrolled data redundancy sets the stage for: 3oor data security& Ha1ing multiple copies of data increases the chances for a copy of the data to be susceptible to unauthori(ed access& Data inconsistency& Data inconsistency e<ists $hen different and conflicting 1ersions of the same data appea in different places& Data integrity is defined as the condition in $hich all of the data in the database are consistent $ith the real-$orld e1ents and conditions& %n other $ords, data integrity means that: J Data are accurateDthere are no data inconsistencies& J Data are 1erifiableDthe data $ill al$ays yield consistent results&

Data anomaly de1elops $hen not all of the re0uired changes in the redundant data are made successfully& The data anomalies found in Aigure &6 are commonly defined as follo$s: - Gpdate anomalies - %nsertion anomalies - Deletion anomalies&

Database system refers to an organi(ation of components that define and regulate the collection, storage, management, and use of data $ithin a database en1ironment& Arom a general management point of 1ie$, the database system is composed of the fi1e ma7or parts: hard$are, soft$are, people, procedures, and data Hard$are& Hard$are refers to all of the systemFs physical de1ices4 for e<ample, computers *3Cs, $or'stations, ser1ers, and supercomputers., storage de1ices, printers, net$or' de1ices *hubs, s$itches, routers, fiber optics.,and other de1ices *automated teller machines, %D readers, and so on. Soft$are& ,lthough the most readily identified soft$are is the DBMS itself, to ma'e the database system function fully, three types of soft$are are needed: operating system soft$are, DBMS soft$are, and application programs and utilities&

+perating system soft$are manages all hard$are components and ma'es it possible for all other soft$are to run on the computers& E<amples of operating system soft$are include Microsoft ?indo$s, )inu<, Mac +S, G2%H, and MKS& DBMS soft$are manages the database $ithin the database system& Some e<amples of DBMS soft$are include MicrosoftFs SL) Ser1er, +racle CorporationFs +racle, SunFs MySL), and %BMFs DB=& ,pplication programs and utility soft$are are used to access and manipulate data in the DBMS and to manage the computer en1ironment in $hich data access and manipulation ta'e place& ,pplication programs are most commonly used to access data found $ithin the database to generate reports, tabulations, and other information to facilitate decision ma'ing& Gtilities are the soft$are tools used to help manage the database systemFs computer components&

3eople& This component includes all users of the database system& +n the basis of primary 7ob functions, fi1e types of users can be identified in a database system: system administrators, database administrators, database designers, system analysts and programmers, and end users& o o System administrators o1ersee the database systemFs general operations& Database administrators, also 'no$n as DB,s, manage the DBMS and ensure that the database is functioning properly& Database designers design the database structure& They are, in effect, the database architects& %f the database design is poor, e1en the best application programmers and the most dedicated DB,s cannot produce a useful database en1ironment& System analysts and programmers design and implement the application programs& They design and create the data entry screens, reports, and procedures through $hich end users access and manipulate the databaseFs data& End users are the people $ho use the application programs to run the organi(ationFs daily operations&

3rocedures& 3rocedures are the instructions and rules that go1ern the design and use of the database system& 3rocedures are a critical, although occasionally forgotten, component of the system& 3rocedures play an important role in a company because they enforce the standards by $hich business is conducted $ithin the organi(ation and $ith customers& 3rocedures are also used to ensure that there is an organi(ed $ay to monitor and audit both the data that enter the database and the information that is generated through the use of those data& Data& The $ord data co1ers the collection of facts stored in the database& Because data are the ra$ material from $hich information is generated, the determination of $hat data are to be entered into the database and ho$ those data are to be organi(ed is a 1ital part of the database designerFs 7ob&

DBMS Aunctions Data dictionary management& The DBMS stores definitions of the data elements and their relationships *metadata. in a data dictionary& %n turn, all programs that access the data in the database $or' through the DBMS& The DBMS uses the data dictionary to loo' up the re0uired data component

structures and relationships, thus relie1ing you from ha1ing to code such comple< relationships in each program& Data storage management&The DBMS creates and manages the comple< structures re0uired for data storage, thus relie1ing you from the difficult tas' of defining and programming the physical data characteristics& Data storage management is also important for database performance tuning& 3erformance tuning relates to the acti1ities that ma'e the database perform more efficiently in terms of storage and access speed& Data transformation and presentation& The DBMS transforms entered data to conform to re0uired data structures& The DBMS relie1es you of the chore of ma'ing a distinction bet$een the logical data format and the physical data format& That is, the DBMS formats the physically retrie1ed data to ma'e it conform to the userFs logical e<pectations& Security management& The DBMS creates a security system that enforces user security and data pri1acy&Security rules determine $hich users can access the database, $hich data items each user can access, and $hich data operations *read, add, delete, or modify. the user can perform& Multiuser access control& To pro1ide data integrity and data consistency, the DBMS uses sophisticated algorithms to ensure that multiple users can access the database concurrently $ithout compromising the integrity of the database& Bac'up and reco1ery management&The DBMS pro1ides bac'up and data reco1ery to ensure data safety and integrity& Current DBMS systems pro1ide special utilities that allo$ the DB, to perform routine and special bac'up and restore procedures& 8eco1ery management deals $ith the reco1ery of the database after a failure,such as a bad sector in the dis' or a po$er failure& Data integrity management& The DBMS promotes and enforces integrity rules, thus minimi(ing data redundancy and ma<imi(ing data consistency& The data relationships stored in the data dictionary are used to enforce data integrity& Database access languages and applicationprogramming interfaces&The DBMS pro1ides data access through a 0uery language& , 0uery language is a nonprocedural languageDone that lets the user specify $hat must be done $ithout ha1ing to specify ho$ it is to be done& Structured Luery )anguage*SL). is the de facto 0uery language and data access standard supported by the ma7ority of DBMS 1endors& Database communication interfaces& Current-generation DBMSs accept end-user re0uests 1ia multiple,different net$or' en1ironments&

, data model is a collection of high-le1el data description constructs that hide many lo$-le1el storage details& , DBMS allo$s a user to define the data to be stored in terms of a data model& Most database management systems today are based on the relational data model& , semantic data model is a more abstract, high-le1el data model that ma'es it easier for a user to come up $ith a good initial description of the data in an enterprise& These models contain a $ide 1ariety of constructs that help describe a real application scenario& The Relational odel

, description of data in terms of a data model is called a schema& %n the relational model, the schema for a relation specifies its name, the name of each field *or attribute or column., and the type of each field& Levels of !"straction in a D# $

The database description consists of a schema at each of these three le1els of abstraction: the conceptual, physical, and e<ternal& Conceptual $chema The conceptual schema *sometimes called the logical schema. describes the stored data in terms of the data model of the DBMS& %n a relational DBMS,the conceptual schema describes all relations that are stored in the database&E<ample, these relations contain information about entities, such as students and faculty, and about relationships, such as students/ enrollment in courses& %hysical $chema The physical schema specifies additional storage details& Essentially, the physical schema summari(es ho$ the relations described in the conceptual schema are actually stored on secondary storage de1ices such as dis's and tapes&?e must decide $hat file organi(ations to use to store the relations and create au<iliary data structures, called inde<es, to speed up data retrie1al operations& , sample physical schema for the uni1ersity database follo$s: J Store all relations as unsorted files of records& *, file in a DBMS is either a collection of records or a collection of pages, rather than a string of characters as in an operating system&. J Create inde<es on the first column of the Students, Aaculty, and Courses relations, the salary column of Aaculty, and the capacity column of 8ooms& Decisions about the physical schema are based on an understanding of ho$ the data is typically accessed& The process of arri1ing at a good physical schema is called physical database design& External $chema E<ternal schemas, $hich usually are also in terms of the data model of the DBMS, allo$ data access to be customi(ed *and authori(ed. at the le1el of indi1idual users or groups of users& ,ny gi1en database has e<actly one conceptual schema and one physical schema because it has 7ust one set of stored relations, but it may ha1e se1eral e<ternal schemas, each tailored to a particular group of users& Each e<ternal schema consists of a collection of one or more 1ie$s and relations from the conceptual schema& , 1ie$ is conceptually a relation, but the records in a 1ie$ are not stored in the DBMS& 8ather, they are computed using a definition for the 1ie$, in terms of relations stored in the DBMS& , DBMS enables users to create, modify, and 0uery data through a data manipulation language *DM).& Thus, the 0uery language is only one part of the DM), $hich also pro1ides constructs to insert, delete, and modify data& TR!&$!CT'(& !&!)E E&T

?hen se1eral users access *and possibly modify. a database concurrently, the DBMS must order their re0uests carefully to a1oid conflicts& , transaction is anyone e<ecution of a user program in a DBMS& *E<ecuting the same program se1eral times $ill generate se1eral transactions&. This is the basic unit of change as seen by the DBMS: 3artial transactions are not allo$ed, and the effect of a group of transactions is e0ui1alent to some serial e<ecution of all transactions& Data Modeling

Data model I is a relati1ely simple representation, usually graphical, of more comple< real-$orld data structures& %n general terms, a model is an abstraction of a more comple< real-$orld ob7ect or e1ent& , modelFs main function is to help you understand the comple<ities of the real-$orld en1ironment& ?ithin the database en1ironment, a data model represents data structures and their characteristics, relations, constraints, transformations, and other constructs $ith the purpose of supporting a specific problem domain& ,n implementation-ready data model should contain at least the follo$ing components: J , description of the data structure that $ill store the end-user data& J , set of enforceable rules to guarantee the integrity of the data& J , data manipulation methodology to support the real-$orld data transformations& Data odel #asic #uilding #locks

The basic building bloc's of all data models are entities, attributes, relationships, and constraints& Entity I anything *a person, a place, a thing, or an e1ent.about $hich data are to be collected and stored& %t represents a particular type of ob7ect in the real $orld, each entity occurrence is uni0ue and distinct& Aor e<ample, a CGST+ME8 entity $ould ha1e many distinguishable customer occurrences, such as 9ohn Smith,3edro Dinamita, etc& Entities may be physical ob7ects, such as customers or products, but entities may also be abstractions, such as flight routes or musical concerts& !ttri"ute I a characteristic of an entity& Aor e<ample, a CGST+ME8 entity $ould be described by attributes such as customer last name,customer first name,customer phone,customer address, and customer credit limit& ,ttributes are the e0ui1alent of fields in file systems& Relationship I describes an association among entities& Aor e<ample, a relationship e<ists bet$een customers and agents that can be described as follo$s: an agent can ser1e many customers, and each customer may be ser1ed by one agent& Data models use three types of relationships: one-to-many, manyto-many, and one-to-one& Database designers usually use the shorthand notations :M or &&M,M:2 or M&&M, and : or && ,respecti1ely& *,lthough the M:2 notation is a standard label for the many-to Imany relationship, the label M:M may also be used&. Examples of relationship (ne*to*many +,- or ,.../ relationship& , painter paints many different paintings, but each one of them is painted by only one painter& Thus, the painter is related to the paintings& Therefore, this relationship B3,%2TE8 paints 3,%2T%2GC is signified as :M& any*to*many + -&or..../ relationship& ,n employee may learn many 7ob s'ills, and each 7ob s'ill may be learned by many employees& Database designers label the relationship BEM3)+-EE learns SE%))C as M:2& (ne*to*one +,-, or ,..,/ relationship& , retail companyFs management structure may re0uire that each of its stores be managed by a single employee& %n turn, each store manager, $ho is an employee, manages only a single store& Therefore, the relationship BEM3)+-EE manages ST+8EC is labeled : & Constraint is a restriction placed on the data& TheyFre important because they help to ensure data integrity and are normally e<pressed in the form of rules& Aor e<ample: ,n employeeFs salary must ha1e 1alues that are bet$een ",### and 6@#,###&

, studentFs G?, must be bet$een &## and =&##&

#usiness rule is a brief, precise, and unambiguous description of a policy,procedure,or principle $ithin an organi(ation& %n a sense, business rules are misnamed: they apply to any organi(ation, large or smallDa business,a go1ernment unit, a religious group or research laboratory& 3roperly $ritten business rules are used to define entities, attributes, relationships, and constraints& The process of identifying and documenting business rules is essential to database design for se1eral reasons: They help to standardi(e the companyFs 1ie$ of data& They can be a communications tool bet$een users and designers& They allo$ the designer to understand the nature, role, and scope of the data& They allo$ the designer to understand business processes& They allo$ the designer to de1elop appropriate relationship participation rules and constraints and to create an accurate data model&

Hierarchical and 2et$or' Models The hierarchical model $as de1eloped in the !"#Fs to manage large amounts of data for comple< manufacturing pro7ects such as the ,pollo roc'et that landed on the moon in !"!& %ts basic logical structure is represented by an upside-do$n tree& The hierarchical structure contains le1els, or segments& , segment is the e0ui1alent of a file systemFs record type& ?ithin the hierarchy, a higher layer is percei1ed as the parent of the segment directly beneath it, $hich is called the child& The hierarchical model depicts a set of one-to-many * :M. relationships bet$een a parent and its children segments& *Each parent can ha1e many children, but each child has only one parent&. The network model $as created to represent comple< data relationships more effecti1ely than the hierarchical model,to impro1e database performance,and to impose a database standard& %n the net$or' model, the user percei1es the net$or' database as a collection of records in :M relationships& Ho$e1er,

unli'e the hierarchical model, the net$or' model allo$s a record to ha1e more than one parent& Some concepts defined during this time $ere: The schema,$hich is the conceptual organi(ation of the entire database as 1ie$ed by the database administrator& The su"schema, $hich defines the portion of the database BseenC by the application programs that actually produce the desired information from the data contained $ithin the database& Data management language *DM).,$hich defines the en1ironment in $hich data can be managed and to $or' $ith the data in the database& Data definition language *DD).,$hich enables the database administrator to define the schema components&

The relational model $as introduced in !5# by E& A& Codd *of %BM. in his landmar' paper B, 8elational Model of Data for )arge Shared Databan'sC&The relational model represented a ma7or brea'through for both users and designers& To use an analogy,the relational model produced an Bautomatic transmissionC database to replace the Bstandard transmissionC databases that preceded it& The relational model foundation is a mathematical concept 'no$n as a relation& To a1oid the comple<ity of abstract mathematical theory, you can thin' of a relation *sometimes called a table. as a matri< composed of intersecting ro$s and columns& Each ro$ in a relation is called a tuple& Each column represents an attribute& The relational model also describes a precise set of data manipulation constructs based on ad1anced mathematical concepts& The relational data model is implemented through a 1ery sophisticated relational database management system *8DBMS.& The 8DBMS performs the same basic functions pro1ided by the hierarchical and net$or' DBMS systems,in addition to a host of other functions that ma'e the relational data model easier to understand and implement& ,rguably the most important ad1antage of the 8DBMS is its ability to hide the comple<ities of the relational model from the user& The 8DBMS manages all of the physical details, $hile the user sees the relational database as a collection of tables in $hich data are stored& Relational diagram is a representation of the relational databaseFs entities, the attributes $ithin those entities,and the relationships bet$een those entities& End*0ser1s perspective $2L*"ased relational data"ase application End*user interface 3 allo$s the end user to interact $ith the data *by auto-generating SL) code.& ! collection of ta"les stored in the data"ase 3 %n a relational database, all data are percei1ed to be stored in tables& The tables simply BpresentC the data to the end user in a $ay that is easy to understand& Each table is independent& 8o$s in different tables are related by common 1alues in common attributes& $2L engine 3e<ecutes all 0ueries, or data re0uests& Eeep in mind that the SL) engine is part of the DBMS soft$are&

Entity*Relationship

odel

, graphical tool in $hich entities and their relationships are pictured& Airst introduced in !5"&E8 models are normally presented in an entity relationship diagram +ERD/,$hich uses graphical representations to model database components& ER odel Components

Entity 3 anything about $hich data are to be collected and stored&8epresented in the E8D by a rectangle,also 'no$n as an entity bo<& The name of the entity,a noun,is $ritten in the center of the rectangle and is generally $ritten in capital letters and is $ritten in the singular form: 3,%2TE8 rather than 3,%2TE8S,and EM3)+-EE rather than EM3)+-EES& Each ro$ in the relational table is 'no$n as an entity instance or entity occurrence in the E8 model& , collection of li'e entities is 'no$n as an entity set& Relationships. describe associations among data& Most relationships describe associations bet$een t$o entities& ?hen the basic data model components $ere introduced, three types of relationships among data $ere illustrated: one-to-many* :M.,many-to-many*M:2.,and one-to-one* : .& ER &otations Chen notation 3 based on 3eter ChenFs land mar' paper& %n this notation,the connecti1ities are $ritten ne<t to each entity bo<& 8elationships are represented by a diamond connected to the related entities through a relationship line& The relationship name is $ritten inside the diamond& Crow1s foot notation I deri1ed from the three-pronged symbol used to represent the BmanyC side of the relationship& The connecti1ities are represented by symbols& Aore<ample, theB Cisrepresented by a short line segment,and theBMC is represented by thethree-pronged Bcro$Fsfoot&C

Cro$Fs foot symbol for (ero or none is +& So

is 4ero*to*many and

is 4ero*to*one .

("5ect*(riented Data

odel +((D /

Both data and their relationships are contained in a single structure 'no$n as an ob7ect . %n turn,the ++DM is the basis for the o"5ect*oriented data"ase management system +((D# $/. The ++DM is said to be a semantic data model because semantic indicates meaning. The ++ data model is based on the follo$ing : & ,n ob7ect is an abstraction of a real-$orld entity& %n general terms,an ob7ect maybe considered e0ui1alent to an E8 modelFs entity& More precisely,an ob7ect represents only one occurrence of an entity& =& ,ttributes describe the properties of an ob7ect& Aor e<ample,a 3E8S+2 ob7ect includes the attributes 2ame, Social Security 2umber,and Date of Birth& 6& +b7ects that share similar characteristics are grouped in classes& , class is a collection of similar ob7ects $ith shared structure*attributes. and beha1ior*methods.& %n a general sense, a class resembles the E8 modelFs entity set& Ho$e1er, a class is different from an entity set in that it contains a set of procedures 'no$n as methods&, classFs method represents a real-$orld action such as finding a selected 3E8S+2Fs name, changing a 3E8S+2Fs name, or printing a 3E8S+2Fs address& %n other $ords,methods are the e0ui1alent of procedures in traditional programming languages& %n ++ terms, methods define an ob7ectFs beha1ior& >& Classes are organi(ed in a class hierarchy& The class hierarchy resembles an upside-do$n tree in $hich each Class has only one parent& Aor e<ample, the CGST+ME8 class and the EM3)+-EE class share a parent 3E8S+2 class& @& %nheritance is the ability of an ob7ect $ithin the class hierarchy to inherit the attributes and methods of the classes abo1e it& Aor e<ample,t$o classes,CGST+ME8 and EM3)+-EE,can be created as subclasses from the class 3E8S+2& %n this case,CGST+ME8 and EM3)+-EE $ill inherit all attributes and methods from 3E8S+2& +b7ect-oriented data models are typically depicted using 0nified odeling Language+0 L/ class diagrams& 0nified odeling Language +0 L/is a language based on ++ concepts that describes a set of diagrams and symbols that can be used to graphically model a system& GM) class diagrams are used to represent data and their relationships $ithin the larger GM) ob7ect-oriented systemFs modeling language&

6uture of Data

odels

7y"rid D# $ are emerging that retain the ad1antages of the relational model and at the same time pro1ide programmers $ith an ob7ect-oriented 1ie$ of the underlying data& These types of databases preser1e the performance characteristics of the relational model and the semantically rich programmatic support of the ob7ect-oriented model& $2L data services8 such as Microsoft SL) Data Ser1ices *SDS. on its ,(ure Ser1ices 3latform,are becoming a critical component of relational database 1endorsF %nternet ser1ice strategies& These BcloudbasedC *that is, remotely processed and %nternet-based.data ser1ices ma'e it possible for companies of any si(e to store their data in relational databases $ithout incurring e<pensi1e hard$are, soft$are,and personnel costs,$hile ha1ing access to high-end database features such as failo1er,bac'up,high transactionrates,and global data distribution& Companies can use a Bpay as you goCsystem based primarily on their storage and band$idth utili(ation and the features used& Degrees of Data !"straction External model is the end usersF 1ie$ of the data en1ironment& The term end users refer to people $ho use the application programs to manipulate the data and generate information& End users usually operate in an en1ironment in $hich an application has a specific business unit focus& Companies are generally di1ided into se1eral business units,such as sales, finance, and mar'eting&

Because data are being modeled,E8 diagrams $ill be used to represent the e<ternal 1ie$s& , specific representation of an e<ternal 1ie$ is 'no$n as an external schema& Conceptual model represents a global 1ie$ of the entire database as 1ie$ed by the entire organi(ation& That is,the conceptual model integrates all e<ternal 1ie$s*entities, relationships, constraints, and processes.in to a single global 1ie$ of the data in the enterprise& ,lso 'no$n as a conceptual schema,it is the basis for the identification and high-le1el description of the main data ob7ects & ,d1antages of Conceptual model & 3ro1ides a relati1ely easily understood birdFs-eye *macro le1el. 1ie$ of the data en1ironment& =& independent of both soft$are and hard$are& $oftware independence means that the model does not depend on the DBMS soft$are used to implement the model& 7ardware independence means that the model does not depend on the hard$are used in the implementation of the model& Therefore, changes in either the hard$are or the DBMS soft$are $ill ha1e no effect on the database design at the conceptual le1el& Generally, the term logical design is used to refer to the tas' of creating a conceptual data model that could be implemented in any DBMS&

'nternal odel is the representation of the database as BseenC by the DBMS& %n other $ords, the internal model re0uires the designer to match the conceptual modelFs characteristics and constraints to those of the selected implementation model& ,n internal schema depicts a specific representation of an internal model, using the database constructs supported by the chosen database&

%hysical model operates at the lo$est le1el of abstraction, describing the $ay data are sa1ed on storage media such as dis's or tapes& The physical model re0uires the definition of both the physical storage de1ices and the *physical. access methods re0uired to reach the data $ithin those storage de1ices, ma'ing it both soft$are- and hard$are-dependent& The storage structures used are dependent on the soft$are*the DBMS

and the operating system. and on the type of storage de1ices that the computer can handle& The precision re0uired in the physical modelFs definition demands that database designers $ho $or' at this le1el ha1e a detailed 'no$ledge of the hard$are and soft$are used to implement the database design& The physical model is dependent on the DBMS, methods of accessing files, and types of hard$are storage de1ices supported by the operating system& ?hen you can change the physical model $ithout affecting the internal model,you ha1e physical independence& Therefore, a change in storage de1ices or methods and e1en a change in operating system $ill not affect the internal model&

&ormali4ation is a process for e1aluating and correcting table structures to minimi(e data redundancies, thereby reducing the li'elihood of data anomalies& 2ormali(ation $or's through a series of stages called normal forms& The first three stages are described as first normal form* 2A.,second normal form*=2A.,and third normal form*62A.& Arom a structural point of 1ie$,=2A is better than 2A,and 62A is better than =2A& Aor most purposes in business database design, 62A is as high as you need to go in the normali(ation process& Ho$e1er, you $ill disco1er that properly designed 62A structures also meet the re0uirements of fourth normal form*>2A.& Arom the data modelerFs point of 1ie$, the ob7ecti1e of normali(ation is to ensure that all tables are at least in third normal form*62A.& E1en higher-le1el normal forms e<ist& Generally, the higher the normal form, the more relational 7oin operations are re0uired to produce as specified output and the more resources are re0uired by the database system to respond to end-user 0ueries& , successful design must also consider end-user demand for fast performance& Therefore, you $ill occasionally be e<pected to denormali(e some portions of a database design in order to meet performance re0uirements& Denormali4ation produces a lo$er normal form4 that is, a 62A $ill be con1erted to a =2A through denormali(ation& Ho$e1er, the price you pay for increased performance through denormali(ation is greater data redundancy& %rime attri"ute any attribute that is at least part of a 'ey &onkey attri"ute any attribute that is described by the primary 'ey or the prime attribute ("5ectives of normali4ation Each table represents a single sub7ect& Aor e<ample, a course table $ill contain only data that directly pertain to courses& Similarly, a student table $ill contain only student data& 2o data item $ill be unnecessarily stored in more than one table *in short, tables ha1e minimum controlled redundancy.& The reason for this re0uirement is to ensure that the data are updated in only one place&

,ll non prime attributes in a table are dependent on the primary 'eyDthe entire primary 'ey and nothing but the primary 'ey& The reason for this re0uirement is to ensure that the data are uni0uely identifiable by a primary 'ey 1alue& Each table is 1oid of insertion, update, or deletion anomalies& This is to ensure the integrity and consistency of the data&

6unctional dependence 3 The attribute B is fully functionally dependent on the attribute , if each 1alue of , determines one and only one 1alue of B& E<ample: 38+9N2GM O 38+9N2,ME *read as B38+9N2GM functionally determines 38+9N2,MEC. %n this case, the attribute 38+9N2GM is 'no$n as the BdeterminantC attribute, and the attribute 38+9N2,ME is 'no$n as the BdependentC attribute& T$o types of functional dependencies that are of special interest in normali(ation are partial dependencies and transiti1e dependencies& %artial dependency e<ists $hen there is a functional dependence in $hich the determinant is only part of the primary 'ey*remember $e are assuming there is only one candidate 'ey.& Aor e<ample, if *,,B. O *C,D., B O C, and *,,B. is the primary 'ey, then the functional dependence B O C is a partial dependency because only part of the primary 'ey *B. is needed to determine the 1alue of C& 3artial dependencies tend to be rather straight for$ard and easy to identify& Transitive dependency e<ists $hen there are functional dependencies such that H O -,- O P,and H is the primary 'ey& %n that case, the dependency H O P is a transiti1e dependency because H determines the 1alue of P 1ia -& , transiti1e dependency $ill occur only $hen a functional dependence e<ists among non prime attributes& %n the pre1ious e<ample, the actual transiti1e dependency is H O P& Ho$e1er, the dependency - O P signals that a transiti1e dependency e<ists& Hence, throughout the discussion of the normali(ation process, the e<istence of a functional dependence among non prime attributes $ill be considered a sign of a transiti1e dependency& To address the problems related to transiti1e dependencies, changes to the table structure are made based on the functional dependence that signals the transiti1e dependencyFs e<istence& Repeating group deri1es its name from the fact that a group of multiple entries of the same type can e<ist for any single 'ey attribute occurrence& The term first normal form * 2A. describes the tabular format in $hich: ,ll of the 'ey attributes are defined There are no repeating groups in the table& %n other $ords, each ro$Qcolumn intersection contains one and only one 1alue, not a set of 1alues& ,ll attributes are dependent on the primary 'ey

The problem $ith the first normal form * 2A. is that sometimes they contain partial dependencies& Second normal form *=2A. has the follo$ing steps: Ma'e ne$ tables to eliminate partial dependencies

8eassign corresponding attributes to their respecti1e tables

Third normal form *62A. has the follo$ing steps: Ma'e ne$ tables to eliminate transiti1e dependencies 8eassign corresponding attributes to their respecti1e tables

'mproving the Design E1aluate 3E ,ssignments E1aluate 2aming con1entions 8efine ,ttribute ,tomicity o ,tomic attribute is one that cannot be further subdi1ided&

%dentify 2e$ ,ttributes %dentify 2e$ 8elationship 8efine 3rimary Eeys as 8e0uired for Data Granularity o Granularity refers to the le1el of detail represented by the 1alues stored in a tableFs ro$&

Maintain Historical ,ccuracy E1aluate Gsing Deri1ed ,ttributes

$2L +$tructured 2uery Language/ Aits into t$o broad categories : %t is a data definition language +DDL/: SL) includes commands to create database ob7ects such as tables, inde<es, and 1ie$s, as $ell as commands to define access rights to those database ob7ects& E<amples are

%t is a data manipulation language *DM).: SL) includes commands to insert, update, delete, and retrie1e data $ithin the database tables&

schema is a group of database ob7ectsDsuch as tables and inde<esDthat are related to each other& Common $2L Data Types

Create a table sample Create a table called tblN3roduct


CREATE TABLE tbl_Product ( prod_id int IDENTITY(1,1) NOT NULL PRI ARY !EY, prod_n"#$ %"rc&"r('() NULL, prod_pric$ #on$) NULL, prod_d"t$ d"t$ti#$ NULL

. %DE2T%T- I $e ma'e a column that creates a uni0ue 1alue for each ne$ ro$ created& Airst argument is increment the number to add to each ne$ created ro$, the second is the seed, $hich determines the starting number 38%M,8- EE- I sets column as primary 'ey 2G)) I column can accept null 1alues 2+T 2G)) I column should ha1e a 1alue

Creating database using SL) Ser1er Management Studio &8ight clic' Databases folder& Select 2e$ DatabaseR

=& Type the database name& Clic' +E

Create a table using SL) Ser1er Management Studio & Select the Database name& 8ight clic' Tables folder& Select 2e$ TableR

=& Type Column name, column data type and chec' if null is allo$ed& %f column is an identity column indicate it in the properties $indo$&

6& Close the $indo$& Type the table name and sa1e the changes&

Data

anipulation Commands

'&$ERT command 3 used to enter data into the table& %ts basic synta< loo's li'e this %2SE8T %2T+ tablename K,)GES *1alues R&1alues2. E<ample : %2SE8T %2T+ tblN3roducts K,)GES *>6,FShampoo DayF,F Q=;Q=# =F.

?e can also insert data in selected columns, %2SE8T %2T+ tblN3roducts *2ame,DateNBought. 1alues *FShampoo DayF,F Q=;Q=# =F.

C(

'T command I any changes committed to the database $ill be sa1ed&

E<ample : C+MM%T4

$ELECT command I used to list contents of the table&The synta< of the command is:

SE)ECT columnnames A8+M tablename -ou could also use a $ildcard character *M. to select all columns from the table&E<ample: SE)ECT M A8+M tablename

0%D!TE command I modify the data in the table& The synta< is : G3D,TE tablename SET columnname S e<pression ?HE8E condition E<ample : G3D,TE tblNAood SET 3G8CH,SEN%D S =,3N2,ME S TEraftF ?HE8E 3N%D S

R(LL#!C9 command I undo any changes to the made since the last C+MM%T command&%t should be e<ecuted before any C+MM%T command is made, other$ise, all changes $ould be made final& DELETE command I used to delete data or ob7ects in our database&Synta< is : DE)ETE A8+M tablename ?HE8E condition

$u"query I or nested or inner 0uery is a 0uery that is embedded or nested inside another 0uery& $electing Rows with Conditional Restrictions SE)ECT columnsQM A8+M tablename ?HE8E condition Comparison operators

0sing Computed Columns and !liases ?e can perform operations on certain columns to return a result such as product,a1erage,sum or the li'es&?e can also use the $ord ,S referred to as alias to rename a certain column result& E<ample :

SE)ECT 38+DGCTNLG,2T%T- M 38+DGCTN38%CE A8+M tblN3roducts SE)ECT 38+DGCTNLG,2T%T- M 38+DGCTN38%CE ,S T+T,)N38%CE A8+M tblN3roducts

Rules of %recedence 8ules that establish the order to $hich computations are computed& & 3erform operations $ithin parentheses =& 3erform po$er operations 6& 3erform multiplication and di1ision >& 3erform addition and subtraction Logical (perators !&D8(R8&(T ?e can use logical operators ,2D,+8 and 2+T to specify conditions in SL)&E<ample SE)ECT M A8+M tblN3roducts ?HE8E *3N38%CE U @## ,2D 3NC,T S TC,8SF. SE)ECT M A8+M tblN3roducts ?HE8E *3N38%CE U @## +8 3NC,T S TC,8SF. SE)ECT M A8+M tblN3roducts ?HE8E 2+T*3NC,T S TC,8SF.

$pecial (perators #ET:EE&: Gsed to chec' $hether an attribute 1alue is $ithin a range& Aor e<ample if $e $ant to list all product information $hose prices is bet$een V@ and V ##, $e can ha1e an SL) of the follo$ing: SE)ECT M A8+M tblN3roducts ?HE8E 38%CE BET?EE2 @# and ## ,lternati1ely $e can also use : SE)ECT M A8+M tblN3roducts ?HE8E 38%CE U @# and 38%CE W ##

'$&0LL: Gsed to chec' $hether an attribute 1alue is null& E<ample $e $ant to chec' all product information that does not ha1e a 1endor information $e can do : SE)ECT M A8+M tblN3roducts ?HE8E KE2D+8 %S 2G))

L'9E: Gsed to chec' $hether an attribute 1alue matches a gi1en string pattern& ?e can use X to indicate any and all follo$ing or preceding characters are eligible, $hile N means any one character can be substituted for the underscore& ,ccess uses M and Y for X and N &E<ample : SE)ECT M from tblN2ame ?HE8E ),STN2,ME li'e T9ohnXF --this sample might include 9ohnson,9ohnsen SE)ECT M from tblN2ame ?HE8E ),STN2,ME li'e TX9ohnF --this sample might include )o9ohn,3aul9ohn SE)ECT M from tblN2ame ?HE8E %D li'e TN# NF --this sample might include ,# ,,,# B,B# B, etc&&& SE)ECT M from tblN2ame ?HE8E ),STN2,ME li'e T9ohnNF --this sample might include 9ohny,9ohns, etcR

'&: Gsed to chec' $hether an attribute 1alue matches any 1alue $ithin a 1alue list& %t can be used to get data $hen a specific condition has been reached either from a set of 1alues, e<ample : SE)ECT M from tblN2ame ?HE8E %D %2 * ##,=##,6##. --this sample $ill get all information ha1ing %D of ##,=## or 6## ?e could also use a sub0uery to act as a filter for the statement& e<ample : SE)ECT M from tblN2ame ?HE8E %D %2 *SE)ECT CN%D from tblNCustomer ?HE8E ),STN2,ME li'e TKXF. --$ill get all list of data from tblN2ame $here the %D matches that of the customer %D ha1ing )ast 2ame starting $ith K

E;'$T$: Gsed to chec' $hether a sub0uery returns any ro$s& %t can be used $hene1er there is a re0uirement to e<ecute a command based on the result of another 0uery& That is,if a sub0uery returns any ro$s, run the main 0uery4 other$ise, donFt& E<ample the follo$ing 0uery $ill list all 1endors, but only if there are products to order: SE)ECT M A8+M KE2D+8 ?HE8E EH%STS *SE)ECT M A8+M 38+DGCT ?HE8E 3NL+H WS 3NM%2.4

(rdering a List (RDER #< clause is especially useful $hen the listing order is important to you& Sample synta< is : SE)ECT columnlist A8+M tablename Z?HE8E condition[ +8DE8 B- columnname ,SCQDESC E<ample $e $ant to order all information in tblN2ame according to A%8STN2,ME: SE)ECT M A8+M tblN2ame +8DE8 B- A%8STN2,ME --default order is ascending, if $e $ant to sort descending $e use: SE)ECT M A8+M tblN2ame +8DE8 B- A%8STN2,ME DESC ?e can also order using multiple column name $ith the column name being follo$ed from left to right SE)ECT M A8+M tblN2ame +8DE8 B- ),STN2,ME,A%8STN2,ME, M%DN2,ME --orders the data by last name, first name and middle name

D'$T'&CT clause produces a list of only those 1alues that are different from one another& Aor e<ample, $e $ant to get the list of all the uni0ue )ast name from the tblN2ame $e can do : SE)ECT D%ST%2CT ),STN2,ME A8+M tblN2ame

!ggregate 6unctions

C(0&T function is used to tally the number of non-null 1alues of an attribute& C+G2T can be used in con7unction $ith the D%ST%2CT clause& E<ample: SE)ECT C+G2T*D%ST%2CT ),STN2,ME. A8+M tblN2ame --counts all distinct )ast 2ame from tblN2ame

'& and

!; e<ample:

SE)ECT M%2*38%CE. A8+M tblN3roduct --displays lo$est 1alue for 38%CE in tblN3roduct SE)ECT M,H*38%CE. A8+M tblN3roduct --displays highest 1alue for 38%CE in tblN3roduct $0 e<ample :

SE)ECT SGM*S,)ES. A8+M tblN3roduct --add up all the 1alues from S,)ES column !=) e<ample : SE)ECT ,KG*S,)ES. A8+M tblN3roduct --gets the a1erage of all the 1alues from S,)ES column

)rouping Data )R(0% #< clause can help in 0uic'ly creating fre0uency distributions&%t can only be used in con7unction $ith aggregate functions C+G2T,M%2,M,H,,KG and SGM&E<ample : SE)ECT DE3,8TME2T,,KG*S,)ES. A8+M tblNSales G8+G3 B- DE3,8TME2T --display the a1erage sales per department 7!='&) clause limits or sets condition for the G8+G3 B- clause, because $e cannot use a ?HE8E clause inside a G8+G3 B- clause& E<ample : SE)ECT DE3,8TME2T,,KG*S,)ES. A8+M tblNSales G8+G3 B- DE3,8TME2T H,K%2G *,KG*S,)ES.U @##. --display the a1erage sales per department $here the ,1erage sales is abo1e @##

>oining Ta"les ?e can use the 3rimary 'ey of one table to lin' to the foreign 'ey of another table to create 7oins&E<ample $e ha1e a tblN2ame $ith 3E of 2%D, $e ha1e another table called tblNSalary ha1ing a 3E of S%D and AE of 2%D& ?e can lin' the tables by using : SE)ECT tblN2ame&),STN2,ME,tblN2ame&A%8STN2,ME,tblNSalary&H8S,tblNSalary&3,-ME2T

A8+M tblN2ame,tblNSalary ?HE8E tblN2ame&2%D S tblNSalary&2%D

?e can also use aliases to our ob7ects to ma'e code shorter&E<ample : SE)ECT 2&),STN2,ME,2&A%8STN2,ME,S&H8S,S&3,-ME2T A8+M tblN2ame 2,tblNSalary S ?HE8E 2&2%D S S&2%D

Das könnte Ihnen auch gefallen