Question

In: Computer Science

List the primary additional datatypes used in a spatial database and provide two example queries that...

List the primary additional datatypes used in a spatial database and provide two example queries that can be run against these datatypes.

Explain the differences in data representation between key:value and document databases. In your answer describe the format of a JSON document, and give an example of a query in a document database

Solutions

Expert Solution

Some of the primary additional datatypes using spatial database are as follows:

  • Geometry spatial data type
  • geography spatial data type

Example of Geometry spatial data type:

CREATE TABLE SpatialTable   
    ( id int IDENTITY (1,1),  
    GeomCol1 geometry,   
    GeomCol2 AS GeomCol1.STAsText() );  
GO  
  
INSERT INTO SpatialTable (GeomCol1)  
VALUES (geometry::STGeomFromText('LINESTRING (100 100, 20 180, 180 180)', 0));  
  
INSERT INTO SpatialTable (GeomCol1)  
VALUES (geometry::STGeomFromText('POLYGON ((0 0, 150 0, 150 150, 0 150, 0 0))', 0));  
GO 

Example of Geography spatial data type:

CREATE TABLE SpatialTable   
    ( id int IDENTITY (1,1),  
    GeogCol1 geography,   
    GeogCol2 AS GeogCol1.STAsText() );  
GO  
  
INSERT INTO SpatialTable (GeogCol1)  
VALUES (geography::STGeomFromText('LINESTRING(-122.360 47.656, -122.343 47.656 )', 4326));  
  
INSERT INTO SpatialTable (GeogCol1)  
VALUES (geography::STGeomFromText('POLYGON((-122.358 47.653 , -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653))', 4326));  
GO  

differences in data representation between key:value and document databases:

Ans:  

A document database is, at its core, a key/value store with one major exception. Instead of just storing any blob in it, a document db requires that the data will be store in a format that the database can understand (i.e. JSON, XML etc). In most doc dbs, that means that we can now allow queries on the document data.

Format of JSON document:

JSON, or JavaScript Object Notation, is a minimal, readable format for structuring data. It is used primarily to transmit data between a server and web application, as an alternative to XML. Squarespace uses JSON to store and organize site content created with the CMS.

Example query for JSON document:

DECLARE @json NVARCHAR(MAX);
SET @json = N'[
  {"id": 2, "info": {"name": "John", "surname": "Smith"}, "age": 25},
  {"id": 5, "info": {"name": "Jane", "surname": "Smith"}, "dob": "2005-11-04T12:00:00"}
]';

SELECT *
FROM OPENJSON(@json)
  WITH (
    id INT 'strict $.id',
    firstName NVARCHAR(50) '$.info.name',
    lastName NVARCHAR(50) '$.info.surname',
    age INT,
    dateOfBirth DATETIME2 '$.dob'
  );
Let me know if you have any doubts or if you need anything to change. 

If you are satisfied with the solution, please leave a +ve feedback : ) Let me know for any help with any other questions.

Thank You!
===========================================================================

Related Solutions

Demonstrate how a temporal database is used in business Explain how spatial databases are used in...
Demonstrate how a temporal database is used in business Explain how spatial databases are used in business Explain how SQL is used with spatial databases Explain how NoSQL databases are being used to store unstructured business data
Discuss the mechanism of primary active transport and provide an example of how it is used...
Discuss the mechanism of primary active transport and provide an example of how it is used in the kidney.
Create the following SQL queries using the lyrics database below 1. List the first name, last...
Create the following SQL queries using the lyrics database below 1. List the first name, last name, and region of members who do not have an email. 2. List the first name, last name, and region of members who do not have an email and they either have a homephone ending with a 2 or a 3. 3. List the number of track titles that begin with the letter 's' and the average length of these tracks in seconds 4....
Identify two types of statistical analyses used in research and provide an example.
Identify two types of statistical analyses used in research and provide an example.
Provide an example of a company that is debt adverse, but could drive additional earnings by...
Provide an example of a company that is debt adverse, but could drive additional earnings by increasing their debt load.
Provide an example of a company that is debt adverse, but could drive additional earnings by...
Provide an example of a company that is debt adverse, but could drive additional earnings by increasing their debt load.
Question 2. The following tables provide some example data that will be kept in the database....
Question 2. The following tables provide some example data that will be kept in the database. Write the INSERT commands necessary to place the following data in the tables that were created in Question 1. Alternatively provide the text files (copy and pasted into your final report) and the open/insert from file commands.. Table: actor act_id | act_fname | act_lname | act_gender 101 | James | Stewart | M 102 | Deborah | Kerr | F 103 | Peter |...
list 100 example of capital used in hospital?
list 100 example of capital used in hospital?
the mysql lyrics database is provided below 1.)What is a primary key used for? Can you...
the mysql lyrics database is provided below 1.)What is a primary key used for? Can you give me an example of a primary key in the Lyrics database? 2.)What is the purpose of doing a join between two tables. Ex. Why would I ever want to join the Tracks and Titles tables together? 3.)Why is isolation important in database design? DROP TABLES IF EXISTS Artists,Genre, Members, Titles, Tracks,SalesPeople,Studios,XrefArtistsMembers; DROP TABLES IF EXISTS Authors,Publishers,Titles,Title_Authors,Royalties; DROP TABLES IF EXISTS Products,Customers,Orders,Order_details; DROP TABLES...
Give an example of a disaster that leads to primary succession and list and explain each...
Give an example of a disaster that leads to primary succession and list and explain each of the steps in the succeeding phases of that succession. How does primary succession differ from secondary succession? What type of succession do we see most commonly associated with clear-cutting of forests?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT