Copyright 2018, Oracle and/or its affiliates. All rights reserved



Download 9,02 Mb.
Pdf ko'rish
bet4/5
Sana03.01.2022
Hajmi9,02 Mb.
#313347
1   2   3   4   5
Bog'liq
json2020

{

"firstName":"John",

"lastName":"Smith",

"age":25,

"address":{

"street":"21 2nd Street“,"city":"New York",

"state":"NY","postalCode":"10021",

"isBusiness":false

},

"phoneNumbers":[

{"type":"home","number":"212 555-1234"},

{"type":"mobile","number":"646 555-4567"}

],

"bankruptcies":null,

”lastUpdated":"2019-05-13T13:03:35+0000"

}

String


Number

Boolean


untyped 

null



Copyright © 2018, Oracle and/or its affiliates. All rights reserved.  | Confidential – Oracle Internal/Restricted/Highly Restricted

What’s JSON? 



{

"firstName":"John",

"lastName":"Smith",

"age":25,

"address":{

"street":"21 2nd Street“,"city":"New York",

"state":"NY","postalCode":"10021",

"isBusiness":false

},

"phoneNumbers":[

{"type":"home","number":"212 555-1234"},

{"type":"mobile","number":"646 555-4567"}

],

"bankruptcies":null,

”lastUpdated":"2019-05-13T13:03:35+0000"

}

String


Number

Object


null

Array



Copyright © 2018, Oracle and/or its affiliates. All rights reserved.  | Confidential – Oracle Internal/Restricted/Highly Restricted

What’s JSON? 



{

"firstName":"John",

"lastName":"Smith",

"age":25,

"address":{

"street":"21 2nd Street“,"city":"New York",

"state":"NY","postalCode":"10021",

"isBusiness":false

},

"phoneNumbers":[

{"type":"home","number":"212 555-1234"},

{"type":"mobile","number":"646 555-4567"}

],

"bankruptcies":null,

”lastUpdated":"2019-05-13T13:03:35+0000"

}

String


Number

Object


null

Array


no Date!


Copyright © 2018, Oracle and/or its affiliates. All rights reserved.  | Confidential – Oracle Internal/Restricted/Highly Restricted

What’s JSON? 



{

"firstName":"John",

"lastName":"Smith",

"age":25,

"address":{

"street":"21 2nd Street“,"city":"New York",

"state":"NY","postalCode":"10021",

"isBusiness":false

},

"phoneNumbers":[

{"type":"home","number":"212 555-1234"},

{"type":"mobile","number":"646 555-4567"}

],

"bankruptcies":null,

”lastUpdated":"2019-05-13T13:03:35+0000"

}

JSON vs XML :

Both hierarchical 



JSON needs no schema

Always UTF8-Unicode 



Fixed data types

No type inheritance, or



substitution groups

no namespaces



….


Copyright © 2018, Oracle and/or its affiliates. All rights reserved.  | Confidential – Oracle Internal/Restricted/Highly Restricted

The schema-less fallacy




Copyright © 2018, Oracle and/or its affiliates. All rights reserved.  | Confidential – Oracle Internal/Restricted/Highly Restricted

The hierarchy problem: JSON data modelling

Copyright © 2017, Oracle and/or its affiliates. All rights reserved.  |

Sample Scenario: School/College

Confidential – Oracle Internal/Restricted/Highly Restricted

 X

Teacher



Course

Student


Student

Student



Copyright © 2018, Oracle and/or its affiliates. All rights reserved.  | Confidential – Oracle Internal/Restricted/Highly Restricted

Copyright © 2017, Oracle and/or its affiliates. All rights reserved.  |

Entity Relationship Model (Peter Chen 1976)

Confidential – Oracle Internal/Restricted/Highly Restricted

 X

Student


Teacher

Course


id

first


grade

empno


name

salary


bank 

account


code

name


Start date

End date


attends

….

teaches



N

N

N



1

last



Copyright © 2018, Oracle and/or its affiliates. All rights reserved.  | Confidential – Oracle Internal/Restricted/Highly Restricted

Copyright © 2017, Oracle and/or its affiliates. All rights reserved.  |

Conversion to JSON

Confidential – Oracle Internal/Restricted/Highly Restricted

 X

Student


Instructor

Course


id

first


grade

empno


name

salary


bank 

account


code

name


Start date

End date


attends

….

teaches



N

N

N



1

last



Copyright © 2018, Oracle and/or its affiliates. All rights reserved.  |

Conversion to JSON

Confidential – Oracle Internal/Restricted/Highly Restricted

17

Student



Instructor

Course


id

first


grade

empno


name

salary


bank 

account


code

name


Start date

End date


attends

….

teaches



N

N

N



1

last


Limited queriability:

How find all 

teachers of a 

student?


Update all 

occurrences of same 

data

Data has to be 



repeated

How to store a 

course without a 

teacher/student?

Inconsistencies 

possible if non-

transactional.

How to find if a 

course if 'full'?

How can this be 

modeled?



Copyright © 2018, Oracle and/or its affiliates. All rights reserved.  | Confidential – Oracle Internal/Restricted/Highly Restricted

Copyright © 2017, Oracle and/or its affiliates. All rights reserved.  |

Conversion to JSON

Confidential – Oracle Internal/Restricted/Highly Restricted

 X

Student


Instructor

Course


id

first


grade

empno


name

salary


bank 

account


code

name


Start date

End date


attends

….

teaches



N

N

N



1

last


Limited 

queriability: 

How find all 

teachers of a 

student?

Update all 

occurrences of 

same data

Data has to be 

repeated


How to store a 

course without a 

teacher/student?

Inconsistencies 

possible if non-

transactional.

How to find if a 

course if 'full'?

How can this be 



modeled?

This is 1966

IBM IMS


hierarchical data model!

We just embarked on a 



50yr time travel! 


Copyright © 2018, Oracle and/or its affiliates. All rights reserved.  | Confidential – Oracle Internal/Restricted/Highly Restricted

JSON support in the Oracle Database

SQL/JSON -> SQL 2016



Copyright © 2018, Oracle and/or its affiliates. All rights reserved.  |

JSON Support in the Oracle database

Confidential – Oracle Internal/Restricted/Highly Restricted

20



JSON storage


Copyright © 2018, Oracle and/or its affiliates. All rights reserved.  |

JSON Support in the Oracle database

Confidential – Oracle Internal/Restricted/Highly Restricted

21



JSON storage

Oracle performance tip:

JSON is always UTF8

-Use ‘al32utf8’ character set if possible

-Use BLOB instead of CLOB

CLOB stores data as UCS2/UTF16

-Use lob data api to insert/fetch data

- getBytes/setBytes instead of 

- getBlob/setBlob!



Copyright © 2018, Oracle and/or its affiliates. All rights reserved.  |

JSON Support in the Oracle database

Confidential – Oracle Internal/Restricted/Highly Restricted

22



JSON storage

JSON value extraction




Copyright © 2018, Oracle and/or its affiliates. All rights reserved.  |

JSON Support in the Oracle database

Confidential – Oracle Internal/Restricted/Highly Restricted

23



JSON storage

JSON value extraction




Copyright © 2018, Oracle and/or its affiliates. All rights reserved.  |

JSON Support in the Oracle database

Confidential – Oracle Internal/Restricted/Highly Restricted

24



JSON storage

JSON value extraction



Oracle functionality tip:

SQL/JSON operators have default for simple usage –

but also many options:

JSON_VALUE(flex, '$.path’ RETURNING NUMBER(4,2),

ERROR ON ERROR

NULL ON EMPTY)

Default return type is VARCHAR2(4000)



Copyright © 2018, Oracle and/or its affiliates. All rights reserved.  |

JSON Support in the Oracle database: Predicates

Confidential – Oracle Internal/Restricted/Highly Restricted

25



JSON storage

JSON value extraction




Copyright © 2018, Oracle and/or its affiliates. All rights reserved.  |

JSON Support in the Oracle database

Confidential – Oracle Internal/Restricted/Highly Restricted

26



JSON storage

JSON value extraction



JSON table projection 




Copyright © 2018, Oracle and/or its affiliates. All rights reserved.  |

JSON_TABLE: ‘flatten’ the JSON




Download 9,02 Mb.

Do'stlaringiz bilan baham:
1   2   3   4   5




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish