DBMS Unit 5 Notes
DBMS Unit 5 Notes
What is RDBMS
2
Relation: a relation is a 2D
table which has the following
features:
Name
Attributes
Tuple
NAME
Issues with RDBMS- Scalability
3
Sharding
4
Scaling RDBMS
Master-Slave Sharding
All writes are written to the
master. All reads are Scales well for both
performed against the reads and writes.
replicated slave databases. Not transparent,
Critical reads may be application needs to be
incorrect as writes may not partition-aware.
have been propagated Can no longer have
down. relationships or joins
Large data sets can pose across partitions.
problems as master needs to Loss of referential
duplicate data to slaves. integrity across shards.
What is NoSQL
5
• Design simplicity
• Simpler horizontal scaling to clusters of machines. This was a
problem in relational databases
• More control over data availability.
Advantages of NoSQL
• Data Storage
• Support for unstructured text
• Ability to handle change over time
• No reliance on SQL magic
• Ability to scale horizontally on commodity hardware
• Support for multiple data structures
• Big data application
• Economy
What is not provided by NoSQL
14
• Joins
• Group by
• ACID transactions
• SQL
• Integration with applications that are based on SQL
Where to use NoSQL
15
• Scalability
• Performance
• High Availability
• Scaling from single server deployments to large,
complex multi-site architectures.
• Key points of MongoDB
• Develop Faster
• Deploy Easier
• Scale Bigger
Example of document oriented database
FirstName = "John",
Address = "Detroit",
Spouse = [{Name: "Angela"}].
FirstName ="John",
Address = "Wick"
Features of MongoDB
Purpose of DTD
Its main purpose is to define the structure of an
XML document. It contains a list of legal elements
and define the structure with the help of them.
employee.xml
<?xml version="1.0"?>
<!DOCTYPE employee SYSTEM "employee.dtd">
<employee>
<firstname>vimal</firstname>
<lastname>jaiswal</lastname>
<email>[email protected]</email>
</employee>
employee.dtd
<xs:element name="employee">
<xs:complexType>
<xs:sequence>
<xs:element name="firstname" type="xs:string"/>
<xs:element name="lastname" type="xs:string"/>
<xs:element name="email" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
XML Schema Example
employee.xml
<?xml version="1.0"?>
<employee
xmlns="http://www.javatpoint.com"
xmlns:xsi="http://www.w3.org/2001/
XMLSchema-instance"
xsi:schemaLocation="http://
www.javatpoint.com employee.xsd">
<firstname>vimal</firstname>
<lastname>jaiswal</lastname>
<email>[email protected]</email>
</employee>
DTD vs XSD
DTD XSD
1) DTD stands for Document XSD stands for XML Schema
Type Definition. Definition.
first.json
{"employees":[
{"name":"Sonoo", "email":"[email protected]"},
{"name":"Rahul", "email":"[email protected]"},
{"name":"John", "email":"[email protected]"}
]}
Features of JSON
• Simplicity
• Openness
• Self Describing
• Internationalization
• Extensibility
• Interoperability
JSON vs XML
{
"employee": {
"name": "sonoo",
"salary": 56000,
"married": true
}
}
PHP JSON
PHP json_encode
<?php
$arr = array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5);
echo json_encode($arr);
?>
Output
{"a":1,"b":2,"c":3,"d":4,"e":5}
PHP JSON
PHP json_decode
mixed json_decode ( string $json [, bool $assoc = false [, int $depth = 512 [, int $options = 0 ]]] )
<?php
$json = '{"a":1,"b":2,"c":3,"d":4,"e":5}';
var_dump(json_decode($json, true));//
true means returned object will be converted into associative array
?>
array(5) {
["a"] => int(1)
["b"] => int(2)
Output
["c"] => int(3)
["d"] => int(4)
["e"] => int(5) }
Java JSON
import org.json.simple.JSONObject;
public class JsonExample1{
public static void main(String args[])
{
JSONObject obj=new JSONObject();
obj.put("name","sonoo");
obj.put("age",new Integer(27));
obj.put("salary",new Double(600000));
System.out.print(obj);
}}
Output {"name":"sonoo","salary":600000.0,"age":27}
Java JSON Decode
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
public class JsonDecodeExample1 {
public static void main(String[] args) {
String s="{\"name\":\"sonoo\",\"salary\":600000.0,\"age\":27}";
Object obj=JSONValue.parse(s);
JSONObject jsonObject = (JSONObject) obj;
Job Tracker:
Splitting into map and reduce tasks
Scheduling tasks on a cluster node
Task Tracker:
Runs Map Reduce tasks
periodically
What is HDFS ?