0% found this document useful (0 votes)
21 views22 pages

Unti 5

DDM UNIT 5 NOTES

Uploaded by

Dexter
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
21 views22 pages

Unti 5

DDM UNIT 5 NOTES

Uploaded by

Dexter
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 22
“ Object Relational and No-SQL Databases srllabus upping EER to ODB schema - Object identifier - reference types - rowlypes - UDTs - Subtypes and apertpes ~ user-defined routines - Collection types - Object Query Language; No-SQL: CAP orem ~ Document-based: MongoDB data model and CRUD operations; Column-based: Hbase ja model and CRUD operations. Contents 51 Object Database Concept 52 Mapping EER to ODB Schema 53 Reference types 54 Row Types 55 User Defined Types 5.6 Subtypes and Supertypes 57 User-Defined Routines 58 Collection Types 59 Object Query Language(OQL) 510 No-SQL 5.11 Types of NoSQL Database 5.12 Comparison between RDBMS and NoSQL 513 CAP Theorem 514 Document-based : MongoDB Data Model and CRUD Operations $18 Column Oriented Database : HBase 516 Two Marks Questions with Answers 6-1) Database Design and Management 5-2 Object Relational and No-SQL. Databases Database Design and Managoment__‘§-2__Otject Relational and No-SQL. Databases ‘Object Database Concept such as inventory, at are w suited to the a wider range of formation systems, real world object and provi ir behavior. It is an alterna FEI mapping EER to ODB Schema *+ Object oriented paradigm encapsulate data and corresponding methods ina single wiented data model helps in adapting object oriented paradigm to database systems. + In object oriented database, information is represented in the form of objects, * Object oriented databases are exact languages. If we can combine object oriented database model. + The « concepts - e object oriented Data model consists of following object oriented Object identifiers are unique. No two objects have the same identifier. each ide © Attribute and method : Every object has state and behavior. The state is a set attributes of the object. The behavior is set of methods. For example - Object ramed circle has state radius and computing its area is a behavior. fi object has only one obje of values TECHNICAL PUBLICATIONS. ~ an up-tmst fr knowledge lass as an tionship). A class is similar to an © Class Hierarchy and Inheritance : the Inheritance property of object mechanism in which a new clas is, EBD Object Structure + Object is a fundamental unit of object oriented and code is encapsulated in a single unit The class hierarchy is used to represent Oriented paradigm. The inheritance is a derived from Programming in which data value + Conceptu: teractions among the objects and rest of the system are carried ‘out by using messages. Thus the interface among various objects and rest of the system is messages. Messages can be implemented as procedure invocations. + In general, an object has associated © A set of variables that contain the data for the object. The value of each variable © A set of messages to which the object responds. © A set of methods, each of which is a body of code -message; a method retums a value as the response to the 4 '* Methods are programs written in general-purpose language wit features - (© Only variables in the object itself may be referenced directly. (© Data in other objects are referenced only by sending messages. © Methods can be read-only or update methods. Read-only methods do not change the value of the object. + For example - the object Circle can have methods such as compute_areal) EEX] object Classes ‘¢ Similar objects are grouped into elasses. In other words, object is an instance of a class. For example ‘lass Student ( [rvariables"/ ‘st RoLNo: g TECHNICAL PUBLICATIONS. -an upinast for know/edge et torts i archy can be defined i M04 tts \ss are as follows Bn Pseudo-code i ‘String name; String address; , class Student is Porson //inbertance: Deriving child clase { {nt Ral; Sting Course taken: ? class Employoo isa Person =a £ 4 date inde; 4 intsalary, : cae Tntr a pee s es ccitoe subclass of Person. Conversely, Person isa superclass of lass Employee. ‘+ Class hierarchy and inheritance of properties from more general classes. + The important benefit of using inheritance is code-reusability. This can be achieved ‘by means of substitutability property. ‘+ Substitutability means any method of a class, say person, can be invoked equally well with any object belonging to any subclass, such as subclass Teacher of Person. _ EEZEN Muttiple inheritance tured organization of classes is adequate to describe applications. In such cases, all superclasses ofa class are ancestors of descendants of another in the hierarchy. However, there are situations that cannot be represented ‘well in a tree-structured class hierarchy. ‘+ Toavoid the conflicts between two occurrences, we use multiple inheritance, Fig. 52.1 Class Hierarchy eS e en upthnist fr knowledge TECHNICAL PUBLICATIONS. an up-ast for knowledge TECHNICAL PUBLICATIONS. ~20 up ee eee, Object Relational and | No-SOU Dataasns se Ee en value is used for identity. For example the primary tional database. at supplied name is used for identity. For example file name ty of abject. ‘into the data model or programming is required. implemented via a unique, system-generated OID. The [A Object Containment ‘+ The objects that contain another objects are called composite objects or complex objects, ‘+ There can be multiple levels of object containment. These levels can be represented using containment hier ‘+ For example - The fol ng Fig. 5.2.3 represents the design of simple document the text in the form of paragraphs. Each paragraph contains © word. Each wor de up of come characters. ' ‘+ Also note that there can be some size and style for each paragraph, word and each character. + The links between classes must be interpreted as is-part-of, rather than the is-a + Containment allows data to be viewed at di For example - document can be vi size and style of paragraphs can editing purpose. An object fen if some or all the values of the v definitions of methods change over time. * The concept of object identity does not apply to tuples of relational data 4 + The containment hierarchy can be used to find all object contained in document stronger notion of identity. E object. The difference between primary of RDBMS and object ID of CODBMS is that _-—-*-‘In certain applications, an object may be contained in several objects. In such case, Primary key is explicit; that me visible to the user whereas the “a the containment relationship is represented by a DAG rather than by a hierarchy. ‘implicit; that means itis hidden from external world, TECHNICAL PUBLICATIONS ~ on up-tust for knowledge TECHNICAL PUBLICATIONS. ~an upstvust for knowledge an Object Relational and No-S0L. Databases bose Design and Management 5:9 Object Relation ot Duet Relational ard Ne-SOL Databases ats se a SL Day 0 Because data types are expected to be simple, and it requites «fy querying mechanism, - Database Design and Managem use of multimedia and other complex data, le. © Hence an object relational system can be used to model this type of system. [il Reference types ‘+ Reference types are all types other than value types. Variables of reference types store a reference to the memory address of the value. * A rreference type value can be stored in one table and used as a reference to specific row in some other table. + To.sea reference type in an SQL statement, use REF(type-name), where typename represents the referenced type. + REF IS SYSTEM GENERATED in a CREATE TYPE statement indicates that the actual values of associated REF type are provided by the system. EX] Row Types a A row type isa sequence of name-datatype pair. It is used to provide a datatype to the rows in the table. Using row type complete row can be stored in a variable. This variable can be passed as an argument to the routine or we can get the retumed value from a function call within this variable. For example - Consider an Employee table containing Emp_Id and address and “empl CHAR(S), ‘address ROW( Strest VARCHAR(30), Cay VARCHAR(25), INSERT INTO Employes ib aeUee ‘VALUES( Account_1294', ROW(11 Shankar Ra’, Chennal ROW “Anand Magee "enc Raa oipona Se eee ee TECHNICAL PUBLICATIONS. ~en up-hnstforarowtce 5:10 Object Relatona and No-S0LDatateany Dotabase Design and Mat EX User Defined Types {uDT)isa datatype derived from an existing data type, ce developer to extend the builtin types and to create g data type that shares ity ing built-in data type. For example = structured type als includes ods enable you to define behavi (CREATE TYPE person AS OBJECT ( name VARCHAR(0), phone VARCHAR) (CREATE TYPE purchase order AS OBJECT ( ute can be accessed using the dot ooperator. For of person then, name = ‘Anand’ allows to assign name tothe arrbute of the person data type. Ed subtypes and Supertypes Supertype : It an entity type that has got the relationship as parent to child ‘or more sul ‘contains attributes that are common to its subtypes. Subtype : The subtypes are group of subtype entity and have unig they are differen from each subtype. e TECHNICAL FUBLICATIONS - an updtnst fer knowledge potabase Design and Managemant For example sere Tear] [temas] [Fes a Fig. 5.6.1 Example of subtype- supertype To create a subtype StudentType ofthe supertype PersonType we write / a8 each subtype contains only unique information. This /inturn leads to a reduction in the size ofthe database itself © 2. Reduction of en ramming operations ona table that corresponds to a specific subtype of an entity. Flexibility in modifying the database structure. There is no need to modify the supertype table if you add / change the structure ofthe subtype table. ER] User-Defined Routines + Userdefined routines are routines that users create themselves. User-defined routines provide a means for users to extend the SQL language. + The User Defined routines capture the functionality of most commonly used arithmetic, string, and casting functions. However, these also allows {0 create routines to encapsulate logic of your own. User-defined procedures, functions and methods are created in the database by executing the appropriate CREATE statement forthe routine type. These routine creation statements include: © CREATE PROCEDURE © CREATE FUNCTION © CREATE METHOD ee TECHNICAL PUBLICATIONS - an up-hnist for Knowledge 3 bet Rebton! and NOS Daaaae, tabs Nameot USE", Tyo Arguments Defined Routine Gata pes | 7 \ oven adzion (04 0AE5R WBOGEN) cases ns enwssen, ————+ Return Valuo neat nD «The causes specific to each of the CREATE statements define chara routine, such asthe routine name, the number and type of routine details about the routine logic. EX collection Types " ‘+ Acallsctionis an onered group of elements having the same datatype, a single column of tbh © LIST: Ordered collection that allows duplicates. © SET: Unordered collection that does not allow duplicates + For example - Array can be created as follows - \VARCHAR(20) ARRAY ARRAY Aichana/AshinAishwarye'’Sharda]; FB object Query Language(oaL) + Object Query Language (OQL) is a query language standard for modeled after SQL. *+ The following rales apply to OQL. statements () Allcomplete statements must be terminated by a semi-colon. TECHNICAL PUBLICATIONS. - an uprutforknowedgo 2) A list of entries in OQL is us byacommay), ©) Strings of text are enclosed by matching quotation marks + Basic From of OQL: SELECT, FROM, WHERE. Where the SELECT clause extracts those elem: condition. By collection get el sets) or expressions Example: Give SEC “SELECT SName! pine Ges ents ofa collection meeting a specific the Keyword DISTINCT duplicated elements in the resling ions in FROM can be either extents (persistent names = toa collection (a set DOT notations and Path expressions We use the dot notation and path expressions to access components of complex values. For example EXER] introduction ‘+ NoSQL stands for not only SQL. ‘+ Ttis nontabular database system that store data differently than relational tables. ‘There are various types of NoSQL databases such as document, key-value, wide column and graph. ‘© Using NoSOQL we can maintain flexible schemas and these schemas can be scaled easily with large amount of data. e TECHNICAL PUBLICATIONS ~an updtrst fer rowide Database Desio and Management ructured data. ase with high availablity, NoSQL is used, es out better than relations) ither schema free or have relaxed schema, That means it does not require specific definition of schema. lultiple NoSQL databases can be executed in distributed fashion. ‘an process both unstructured and semi-structured data. ne need for it. Enlist various feature of NOSQL. ERM Types of Nosa Database types of NoSQL databases and those are - v5 1. Key-value store 2 Document store 3. Graph based 4._Wide column store etus discuss themin det FREED Key-vaiue store + Key-alue} There are the simplest type of NoSQL database, r TEOMNICAL PUBLICATIONS: «an upinastorkncwedge s designed in such a way to handle ots of data «In the key-value storage the key is unique and Binary objects. + Forexample- ‘and heavy load, the value can be JSON, string or sida u Here id, name are the keys and 12, “Ankita, Praja” are the values comesponding to those keys. Key-value stores help the developer to store schema-less data . They work best for shopping Cart Contents. ‘The DynamoDB, Riak, Redis are some famous examples of key-value store, ERIE Document store *+ The document store make use of key-value pair to store and retrieve data tis most commonly used due to flexibility and ability to query on any fed. + Forexample- ‘MongoDB and CouchDB are two popular document oriented NoSQI. database. El Graph ‘The graph database is typically used in the applications where the relationships among the data elements isan important aspect. The connections between elements are called links or relationships. In a graph database, connections are first-class elements iabase, stored directly. In relational databases, links are implied, using data to expres the relationships. TECHNICAL PUBLICATIONS. ~an pst for knowl 2) Edge For example - ot) ‘graph databases are FRIED Wide column Store model ‘model number of columns are not fixed for each record. leis non-relatonal data bose system Hea etn dtu eine 3 thas predefined schema, 4, WeusesSQL to query the database, isa tble based database ‘Optimistic: amples? Mingabo, gabe Reds . databases can quickly aggregate the value of a given column, Z one + Forexample F [nono Calumns. Ta] (Greer es ROR NSO Fi ; | | Name city ERE cAP Theorem | “Ankita Pune ‘* Cap theorem is also called as brewer's theorem. 2 cay all + The CAP Theorem i comprised of three components (hence its name) as they relate Mumbai Tovialegmallm a ceed data shes I reads receive the most recent write o an errr. ised to manage data warehouses, business se, Cassandra are examples of column based databases. 1._Explain diferent types of NOSQL databases ae $$$ TECHNICAL PUBLICATIONS en uptnast fr knowodgo reads contain data butit might not be the most recent. connections between nodes.) + The CAP theorem states that properties - consistency, distributed system with data replication ee TECHNICAL PUBLICATIONS. ~anupitras for irowiodye lerance : The system continues to operate despite network failures (ie; dropped partitions, slow network connections, or unavailable network not possible to guarantee al three ofthe desirable ,,and partition tolerance at the same time in a Object Relational and No-SQL Databases Dtabose Design and Management ERE document - based : MongoDB Data Model and CRUD Operations JoDB is an open source, document based database. lope and supported by a company named 10gen which is now MongoDB Ine. «Tho first eady version of MongoDB was released in March 2010, Why MongoDB Is needed ? MongoD8. Fig. 5.141, Consider a student database as follows - To the left hand side we show the database in the form of table and to the right hand side the database is shown in the form of collection. Features of MongoDB. ;ports multiple storage engines, a rich query language support. 5) MongoDB provides high avs That means it creates Name Course ‘Asdresatnet [Adresaine| ‘kta | CometerErarening | taret | ane Prania | MechankalEngneeing | vee" | Sree Kevia | Owl Enperng oast_| _Rosed e cond raits towhich dat 3 SOL Structure Vs. MongoD Following fi MongoDB the data Fig. 5.14.2 Representation of relational and document based schema EXER] pata Types Following are various types of data types supported by ‘MongoDB. 1) Integer : This data type is used for storing the numerical value. Se ee TECHNICAL PUBLICATIONS. -anupitt fr nowiodse ime manner the rows in, lad documents in Mon, nisin MongoDB, unns of the record in RDBMS, fields, eee TECHNICAL | PUBLICATIONS) - on ‘up-thrust for knowledge Object Relational and No-SQL Databasag. — Ceject Reltonal re NO SOL Patabaseg used to comp ue against the lowest or this datatype is pe is used to store fe can also create our 0 © TECHNICAL PUBLICATIONS. ~an uot fornawlodge PS Sep Wielcome to the MongoD8 4.4.4 2008R2PIus SSL (64 Bt) Setup Wizard (Wher npr Out ea ona res hoose the Complete option for installation, Follow the mn by clicking the Next button. Just eck on Next but normal procedure o Finally you wi 1g window on successful installation, [ ongcD8 44 2008R2Pus SL (HDD Sep = % ‘Completed the MongoDB 4.4.4 2008R2PIus SSL (64 bit) Setup Wizard ck te Fe ban athe Sen Wad. TECHRUGAL PUBLICATIONS. -anupitat or Ane installed correctly oF not, go to command prompy. command for mogod.exe file’s version. It is ‘“— ‘ To set the environment variable, Open System Properties and click on En Variables Tomo natin ciomienoe TECHNICAL PUBLICATIONS - on uptist for knowidD® 526 bet Reto ard No-SOL Dataaay $$ nt Databases 1g ok bution and just come out of the environenen, ogeent Dutatos Deg ond Manage ” rating 5 ; ws9Stem OF Abi, have cosnfillowingane ee te 8 Windows wing option. tinue clicking 1w and now simply issue th art your command prompt window and now simply issue the command mong jan go atthe command prompt wieov. It will recognise this command gn 1.260 (Static) 1g Mongod Compass (Graphical Too!) very useful for handling MongoDB database with the help of simple palaces Click on the Download button. The exe file will get downloaded. Double installer file which is downloaded in your PC and the installation process fo q 4 Compass will start copa |} = = x ‘Welcome tothe MongoDB Compass Setup Wizard ‘eva nt tt Hog Compaen pete et eee e TECHNICAL PUBLICATIONS. an upiinstxnowled® = TECHNICAL PUBLICATIONS an upto knnlodgo pleted the MongoDB Compass Setup rd Application and sim, following GUI "Coma muon mesma oma a short form of the Create, Read, Update and Delete .s. These operations are the basic operations that are normally peeformed on any sabase Commands section we will discuss how to create and handle database in MongoDB using mmand prompt and type the command mongo f will appear. For creating a database we need to oon TECHNICAL PUBLICATIONS. ~enuparst ‘To chock the currently sclevted database, use the command db Note that in above listing we can not see the mystudents database. This have not inserted any document into it. To get the name of the database in the ‘means of show command, there should be some record present in the database, (2) Drop Database ottod ce ae aT “jncolloction name inser ( (keys er -example= = Sa ro ae SAAR "Salary? a Fy": 10000)) We can crossverfy whether the clleton is created or not by ung command following Note that the one document(analogous to row) is getting inserted in the colletion named myemp. = ‘TECHNICAL PUBLICATIONS -an updhnst fo knoe p< ae __ cst felt an SO. Da foarte SOL Oa seateCollection command, Database Design and Managornert a name is the nam let nr when i eaces to maxim ec rable capped collection. When you spect you need to specify the size parameter. | Capped collection isa fixed size collection It automatically "student _details") (4) Display Collection (Read Operation) To check the created collection use the command “show collections” at the command prompt a TECHHICAL PUBLICATIONS: - an uprust or knowledge tion("Student_ detailer) 19)0r0p Caltection (Delete Operation) irop collection command is actual 2 ally used to remove the collect rom the database. The drop command Femoves a collection, es completely ly from database, syntax 7 Gp collection ame dropt) For example TB command Promet manga |, dp-student_details.dropcy We can verify the deletion of the collection by using “show collections” in the database (@)insert Documents ‘The document is inserted within the collection. The document is analogous to rows in database. syntax pea bs ole aii Be iy aa) ‘TECHNICAL PUBLICATIONS” -an updtvst er knowiadpe cnet Reatonal and No-SOL Databases raveee NOSOL Databases Inserting Muttiple Documents It is possible to insert multiple documents at a time using a single command. Fetiowing seers shows how to insert multiple documents in the existing collection, TECHNICAL PUBLICATIONS 60 up-tirus for brcledge tthe 3 documents have been inserted by this command. fy the existence ofthese documents in the collection you can use find command (7) Delete Documents: For deleting the document the remove command is used. Ths i the simplest command. Syntax. ‘tactics ania remave( Galatea For example = First of all we can find out the docut ce onmind ng ‘TECHNICAL PUBLICATIONS. ="! ptt fr know nents present in the collection using Find) Note that there were two records that were matching with age=20 with name “BBB and “EEE”, but since we have passed justOne attribute as 1, we get the result by deleting, the single record having name “BBB” Remove all the documents It is possible to remove all the documents present inthe collection withthe help of Deleting only one Document single command. Sometimes the delete criteria matches for more than one records and in such si Syntax 2a ‘we can forcefully ell the MongoDB to delete only one document, ‘eb collection “namie romove ~— Syntax For example ‘i cobttion aoe seid eter, juste)” oat ‘The justOne isa Boolean value it can be 1 or 0. If we pass this value as 1 then document will get deleted, TECHNICAL PUBLICATIONS" -onuptntar noodye ee TECHNICAL PUBLICATIONS 2719s — 5-36 Otc Relational and No-SOU Databases Datadece Seson ana Management _$-36 _Oovet Felatonel and No-SO4 Dotabaggg Deere See ee the update command updates a sng rments as Well. For that purpose we hat (8) Update Documents e document we provide some criteria based on Which the doo can be updated. Syntax (Gp collection ame updato(criveria.update data) ay For example - Suppose the collection “Student contain following documents rnd we want to Gnge the name “CCC” to "WWW", ten she command Ga oe x | Thus the document gets updated, = 7 2 TECHHUCAL PUBLICATIONS. - an upstrus for knowledge a TECHNICAL PUBLICATIONS. an upiirst fr Kowa Object Relational and No-SOL Datatasog swe issue following command EEE column Oriented Database : HBase EKER concept of Column Oriented Database columnoriented database is a database system that stores the data table by ted Database is that we can lumns is used for querying. The aniket_technical@ gmail.com Database Design and Management 5-39 o _Objct Relations! and to SOL Datatsos olumn-oriented database is highly used for Big data applications benefit of a column-based DBMS is sein ional database schema, '5) We can use aggregation for vast amount of data EEF Introduction to Hbase Data Model + HBase is a column oriented non-elational database management system. Itruns on top of Hadoop Distr le System(HDFS). + HBase is an Open-source technology developed by Apache Software Foundation +The HBase can store massive amount of data from terabyte to petabytes. wlexing, which uses less disk Features of HBase Data Model 1) HBase is horizontally scalable, That means we can add any number of columns anytime. 2) The datas stored in key value format. 3) It is a platform for storing and retrieving data with random access, 4) It does not enforce relationship within the data, 5) It is designed to run on cluster of computers Difference between ROBMS and HBase ‘Sr.No. ‘RDBMS 1 | Terequires SOL 72 | Ithas fixed schema, ‘emall_address Is row-oriented ashwini abe@ gmail.com Wwe can see that a column family has several rows, Within each row, there can be ‘several different columns, with different names, links, and even sizes Advantages of Column oriented dat f column oriented database is faster performance latabase 2) The column-oriente: labase can store more data in smaller amount of memory. oe? TECHNICAL PUBLICATIONS. - an pstrst or kronladye tis static nature ‘The data retrievalisclower. Tin RDBMS, the datas normalized ‘accomodates small tables, ERER) HBase CRUD Operations 1s. In onder to The CRUD stands for Create, Read, Update and Delete Ope In are verified by > CREATE ‘customer’ ef oe or cell. The syntax is ieee commana is used t ead the contents of rove or cell. The synt Reading a s : ‘baselimain) 018 0> got eustomer, ', (COLUMN = 'cfname'} COLUMN cau. fname timestamp = 1418035791555, value ~ Supriya 1 row() in 0.0080 seconds 3) Insert Data : ble is created using list command. For example e TECHNICAL PUBLICATIONS” - an uptrustfor knowledge 14) Update Operation : column families or we can modify the table « VERSIONS: ‘We can modify some properties of existin, 6 table using alter command. We add more a - tributes. The syntax is ater , NAME=>! Esha fad ames atone 7 - To add the column family staus in able‘castomer eating | 1d to keep a maximum of 5 cells > alor ‘customer’, NAMES staid, VERSIONS Zs To delete some column family ‘status’ we use alter coms = mand as > alter a NAMES aka’ GD ws ala? ss Soliran name>?" I ‘code is encapsulated in a single unit which data value and 1 fundamental unit of object oriented programming in which data s “TECHNUCAL PUBLICATIONS -an upto krowlcye name-dattype pait It is used to pro therowsinthe table Using 10 OPS rd syne? ean sy ype tht has got the relationship as parent fo a tec 15 pti hae ear os mutual? me eer «+ Itisnontabulae database system tht store data differently than relational 7 Whatis CAP theorem? iste system with data rel Enlist features of MongoD8, as 1) Misa schematess, document based database system. complet row canbe stored ina variable, Relational and No-SOL Databases “qa _ What s column-oriented database model? Give example fit ‘ane. + The column-oriented database isa database system that stores the data table by oiuenn rater than by rows, The advantage of colummriented Database is that we can cess the data more efficiently when only subset of columns is used for querying. For example - HBase 30 nls the features of HBase data model, ans. 1) HBase is horizontally scalable. That means we can add any number of columns anytime, 2) The data is stored in key value format. {orm for storing and retrieving data with random access. snforce relationship within the data, torrun on cluster of computers. TECHNICAL PUBLIGATIONS. =n uptrest or know

You might also like