Unit - 6
Advances in Databases
Q1) What is an active database?
A1) A database with a set of triggers is known as an active database. Because of the complexity involved in understanding the effects of various triggers, maintaining these databases is extremely tough. Prior to executing the statement in such a database, the DBMS examines if the specific trigger indicated in the statement that modifies the database is enabled or not.
If the trigger is active, the condition section is executed first, followed by the action part only if the stated condition is true. It is possible to use a single sentence to activate many triggers.
In this case, the DBMS processes each of the triggers at random. The execution of a trigger's action portion may activate other triggers or the same trigger that initiated the action. The term "recursive trigger" refers to a type of trigger that triggers itself. Although the DBMS performs such trigger chains in a pre-defined manner, it has an impact on the concept of comprehension.
Features
● It has all of the features of a traditional database, such as data modeling capabilities and query language, multi-user access, and recovery.
● It has all of the features of a standard database, such as data definition, data manipulation, and storage management.
● Data definition, data manipulation, storage management, transaction management, concurrency control, and crash recovery are all supported, as are all the operations of a typical database.
● ECA-rules are defined and managed using an active database.
● An active database must be able to detect the occurrence of events.
● An active database must be capable of evaluating conditions and carrying out activities.
● An event-driven architecture is part of an active database (often in the form of ECA rules)
● An active database should be programmable and support a programming environment.
Application
- Applications that rely on data monitoring activities, such as CIM, Telecommunications Network Management, Program Trading, Medical, and Financial Decision Support Systems, can benefit considerably from active database integration.
- Controlling production, such as in power plants.
- Routine maintenance, such as inventory control.
- Financial applications, such as trading stocks and bonds.
- Network and telecommunications management.
- Air traffic control.
- Computer Integrated Manufacturing (CIM)
- Tools for compiling statistics and authorizing transactions.
Weakness
● There is a lack of methodological support in the design and analysis.
● Standardization is lacking.
● Triggers are missing development and administration tools.
● Poor performance: One of the primary reasons why users are hesitant to employ active rules in the creation of large applications is because of their poor performance.
● The isolation of transactions and triggers, as well as the misunderstanding of their delicate interconnections, make it difficult to optimize large programs.
● Many active database management system prototypes lack support for application development.
● Active databases have mostly been considered in centralized database setups, hence distribution and parallelism have not been frequently considered.
Q2) Write about deductive databases?
A2) Not just facts, but also general principles, are stored in a deductive database. These rules can be used to infer new facts that aren't explicitly reflected in the database; data can be stored implicitly using these rules.
Take a look at the deductive database below:
“John is Bill’s father.” “Bill is Derek’s father.”
“IF x is y’s father AND y is z’s father, THEN x is z’s grandfather.”
This database also contains a rule that indicates the grandfather relationship between two entities, in addition to the two facts. By substituting x = "John," y = "Bill," and z = "Derek" into the formula, the database can establish the statement "John is Derek's grandfather."
This type of rule has the effect of defining new relationships that aren't explicitly recorded in the database. Implicit or virtual relationships are what they're called. Base relations are explicit relationships, such as the father relationship described above.
The intensional database (IDB) is a collection of virtual relations, whereas the extensional database is a collection of basic relations (EDB). First-order logic is used in deductive database systems. We can express both facts and rules about facts using the same vocabulary using first-order logic.
A deductive database is a database that has been enhanced with an inference system. Deductive databases arose from a desire to integrate logic programming and relational databases in order to build systems that enable a powerful formalism.
Database + Inference → Deductive database
The immediate benefit is that it may be possible to reduce the amount of storage space required for data.
We often express rules in a deductive database system using a declarative language—a language in which we specify what we want to do rather than how we want to achieve it.
By interpreting these rules, a system's inference engine (or deduction mechanism) can derive new facts from the database.
Although deductive databases are not widely utilized outside of academics, some of its concepts are used in relational databases today to support the advanced features of more contemporary SQL standards.
Specification
● Prolog was utilized as a starting point for logic-based deductive database work. Datalog, a variant of Prolog, is used to declaratively define rules in conjunction with an existing collection of relations, which are handled as literals in the language.
● Facts and rules are the two sorts of specifications used in a deductive database.
● Data saved as relations in a relational database is referred to as facts.
● Facts are expressed similarly to relations, with the exception that attribute names are not required.
● Relational views and rules have a lot in common. They define virtual relationships that aren't actually recorded but can be derived from facts using inference techniques based on rule descriptions.
Q3) Write short notes on the main memory database?
A3) The Main Memory Database is permanently stored in the system's Main Memory. On the hard drive, there is a backup copy of the database. In contrast to database management systems, which use a disk storage method, it primarily relies on main memory for computer data storage. In Memory Database is another name for it.
The main memory database is a database system that stores computer data largely in main memory. Because disk access is slower than memory access, they are faster than disk-optimized databases. Additionally, the internal optimization is simpler and uses fewer CPU instructions.
Features
● Data can be accessed directly and shared memory architecture is used.
● There is no data duplication or network overhead.
● They are inextricably linked.
● They happen at the same time.
● Transactions that are completely ACID.
Advantages
● It uses shared memory architecture and has immediate access to data.
● It's written by hand with atomic instructions.
● It has allocators with fixed and variable sizes.
● The performance-critical code parts are tightly connected.
Disadvantages
- It's possible that they won't be cost-effective.
- There is a chance that data will be lost.
- The database has a capacity limit.
Applications
● Embedded real-time systems use this.
● In an MP3 player, manage the music databases.
● Data programming in set-top boxes, mathematical trading, and other financial applications are all examples of this.
● Sites for e-commerce and social networking.
Q4) What do you mean by semantic database?
A4) The semantic data model (SDM) is a database description and organizing formalism (database model) based on semantics. This database model is intended to capture more of the meaning of an application environment than current database models allow. The types of entities that exist in the application environment, their classifications and groups, and the structural relationships among them are all described in an SDM specification. SDM is a set of high-level modeling primitives that can be used to capture the semantics of an application environment.
SDM allows the same information to be seen in several ways by including derived information in a database structure definition; this allows it to directly satisfy the wide range of needs and processing requirements that are common in database applications. The current SDM was created based on our experience with an early version of it. SDM is a database management system that aims to improve the efficiency and usability of database systems.
An SDM database description can be used as a formal database specification and documentation tool, as well as a foundation for supporting a variety of powerful user interface facilities, a conceptual database model in the database design process, and the database model for a new type of database management system.
Semantics is a new branch of information science research and development, however the concept has been around much longer than computers! To begin, semantics is the discipline of linguistics and logic that deals with the concept of meaning. This can be broken down into three major categories:
● Formal Semantics
○ Logical aspects of meaning:
■ Sense
■ Reference
■ Implication
■ Logical form
● Lexical Semantics
○ Word meaning
○ Word relations
● Conceptual Semantics
○ Cognitive structure of meaning
To begin, the phrase "semantic data model" is traditionally used in conjunction with the term "semantic database." When you hear the term "semantic data," it usually conjures up images of the Semantic Web, Web Ontology Language (OWL), and Resource Description Format (RDF).
Semantic web
"The semantic web is a vision of information that can be easily interpreted by machines, allowing machines to do more of the laborious work of discovering, combining, and acting on web data." The Semantic Web is a system that allows machines to "understand" and reply to complicated human queries based on their meaning, as it was originally envisioned.
OWL and RDF
Unfortunately, OWL and RDF have taken over the original concept and language coined by Tim Berners-Lee (also the inventor of the World Wide Web). Subject-predicate-object expressions are the emphasis of OWL and RDF, where "the subject denotes the resource, and the predicate denotes qualities or aspects of the resource and expresses a relationship between the subject and the object."
It all started in the 1960s, when "Richard Montague devised a system for defining semantic entries in the lexicon in terms of the lambda calculus." The syntactic parse of the sentence John ate every bagel would be constituted of a subject (John) and a predicate (eat every bagel); Montague demonstrated that the meaning of the sentence could be dissected into the meanings of its pieces and a few rules of combination."
Q5) Explain semi structured data?
A5) Semi-structured data comprises tags or other types of mark-up that identify separate, distinct things within the data, but does not comply to the standards of regular structured data.
Nested data structures and the lack of a fixed schema are two major characteristics that separate semi-structured data from structured data:
● Before structured data can be imported and queried in a relational database system, a fixed schema must be specified. Semi-structured data does not require the creation of a schema in advance and can change over time, with new properties being added at any moment.
Furthermore, even though they are grouped together, entities inside the same class may have various properties, and the order of the attributes is irrelevant.
● Semi-structured data, unlike structured data, which is represented as a flat table, can contain n-level hierarchies of nested information.
Data that does not correspond to a data model but has some structure is referred to as semi-structured data. It doesn't have a set or rigid structure. It's information that isn't stored in a logical database but has some organizational characteristics that make it easier to analyze. We can save them in a relational database with the help of various procedures.
Sources of semi structured data
● E-mails
● XML and other markup languages
● Binary executables
● TCP/IP packets
● Zipped files
● Integration of data from different sources
● Web pages
Q6) Write the features and advantages of semi structured data?
A6) Features
● Although data does not follow a data model, it does have some structure.
● Data cannot be kept in rows and columns like it can in databases.
● Tags and elements (metadata) are used to group data and explain how it is kept in semi-structured data.
● Identical entities are grouped and organized in a hierarchy.
● The attributes and properties of entities in the same group may or may not be the same.
● There is insufficient metadata, making data automation and management challenging.
● In a group, the size and type of the same properties may differ.
● It is difficult for computer programs to use due to the lack of a well-defined structure.
Advantages
● A predefined schema does not confine the data.
● Schema is flexible, in the sense that it can be easily altered.
● Data can be moved around.
● Structured data can be viewed as semi-structured data.
● It assists customers who are unable to explain their requirements in SQL.
● It can handle a wide range of sources with ease.
Q7) Describe JSON?
A7) JSON (JavaScript Object Notation) is a data-exchange format based on a subset of the JavaScript Programming Language.
Any program can generate JSON data. Among the most common instances are:
● Native methods are used by JavaScript applications to generate JSON.
● Non-JavaScript apps generate JSON data using libraries (typically with extensions).
● JavaScript generators that can be used on the fly.
● JSON documents are concatenated (which may or may not be line-separated).
There are major discrepancies between various implementations due to the lack of a written specification. Because of these differences, importing JSON-like data sets is impossible if the JSON parser's language specification is rigorous. Snowflake follows the concept "be liberal in what you accept" to make importing JSON data sets as painless as possible. The goal is to take as many JSON and JSON-like inputs as feasible, allowing for unambiguous interpretation.
Basic JSOn Syntax
JSON data is a collection of name/value pairs organized into objects and arrays in a hierarchical structure:
● Colons: separate names and values in name/value pairs.
● Curly braces {} denote objects.
● Square brackets [] denote arrays.
● Commas, separate entities in objects and arrays.
Syntax and structure
A JSON object is a data format that uses curly brackets to represent key-value pairs. When working with JSON, you'll most likely see JSON objects in.json files, but they can also exist in the context of a program as a JSON object or string.
The following is an example of a JSON object:
{
"first_name": "Sammy",
"last_name": "Shark",
"location": "Ocean",
"online": true,
"followers": 987
}
Although this is a very small example, and JSON can be many lines long, it demonstrates how the format is often set up with two curly braces (or curly brackets) on either end, and key-value pairs filling the space in between. The majority of data in JSON is wrapped in a JSON object.
Key-value pairs have a colon between them as in "key": "value". Each key-value pair is separated by a comma, so the middle of a JSON looks like this: "key": "value", "key": "value", "key": "value". In our example above, the first key-value pair is "first_name": "Sammy".
On the left side of the colon are JSON keys. They must be included in double quotes, as in "key," and can be any valid string. Keys within each object must be distinct. These key strings can contain whitespaces, such as "first name," but this makes it more difficult to access while programming, therefore use underscores instead, as in "first name."
Name / Value pair
A field name (in double quotes), a colon, and then a value makes up a JSON name/value pair.
Example
{"firstName":"John", "empid":45611}
Supported data types
A value in a name/value pair can be:
● A number (integer or floating point)
● A string (in double quotes)
● A Boolean (true or false)
● An array (in square brackets)
● An object (in curly braces)
● Null
Q8) Illustrate xml with example?
A8) The markup language XML (Extensible Markup Language) offers a set of rules for encoding texts. It was based on SGML, another markup language that was created to standardize the structure and elements of a document.
Since its initial concentration on documents, XML has expanded to include a wide range of applications, including the representation of arbitrary data structures and serving as the basic language for communication protocols. It has become one of the most widely used protocols for data interchange on the Web due to its extensibility, versatility, and usability.
The following constructs make up the majority of an XML document:
● Tags (identified by angle brackets, < and >)
● Elements
Elements are normally made up of a “start” tag and a corresponding “end” tag, with the text between the tags forming the element's content. An element can also be made up entirely of "empty-element" tags with no "end" tags. The “start” and “empty-element” tags can have attributes that help describe the element's properties or metadata.
Example
<?xml version="1.0"?>
<!DOCTYPE parts system "parts.dtd">
<?xml-stylesheet type="text/css" href="xmlpartsstyle.css"?>
<parts>
<title>Automobile Parts & Accessories</title>
<part>
<item>Spark Plugs</item>
<partnum>A3-400</partnum>
<price> 27.00</price>
</part>
<part>
<item>Motor Oil</item>
<partnum>B5-200</partnum>
<price> 14.00</price>
</part>
<part>
<item>Motor Oil</item>
<partnum>B5-300</partnum>
<price> 16.75</price>
</part>
<part>
<item>Engine Coolant</item>
<partnum>B6-120</partnum>
<price> 19.00</price>
</part>
<part>
<item>Engine Coolant</item>
<partnum>B6-220</partnum>
<price> 18.25</price>
</part>
</parts>
Q9) Describe object relational database?
A9) An object–relational database (ORD) or object–relational database management system (ORDBMS) is a database management system (DBMS) that is similar to a relational database but uses an object-oriented database model in which objects, classes, and inheritance are supported directly in database schemas and query languages. It also allows for the extension of the data model with custom data types and procedures, exactly as pure relational systems.
An object–relational database is a type of database that sits halfway between relational and object-oriented databases. The methodology in object–relational databases is substantially the same as in relational databases:
At one extreme are OODBMSes, in which the database is essentially a persistent object store for software written in an object-oriented programming language, with a programming API for storing and retrieving objects and little or no specific support for querying; at the other extreme are OODBMSes, in which the database is essentially a persistent object store for software written in an object-oriented programming language, with a programming API for storing and retrieving objects, and little or no specific support for querying
The primary requirement for an object–relational database stems from the reality that both relational and object databases have distinct advantages and disadvantages. The relational database system's isomorphism with a mathematical relation allows it to apply many relevant set theory techniques and theorems.
However, these databases aren't ideal for certain sorts of applications. Containers such as sets and lists, as well as arbitrary user-defined datatypes and nested objects, are all possible in an object-oriented database paradigm. This eliminates the issue of impedance mismatch by bringing application type systems and database type systems closer together. However, unlike relational databases, object databases do not provide a mathematical foundation for extensive analysis.
One of the ORD's objectives is to close the gap between relational and object-oriented database conceptual data modelling techniques such as the entity-relationship diagram (ERD) and object-relational mapping (ORM). It also aims to connect the gap between relational databases and the methods of object-oriented modelling that are commonly used in programming languages such as Java, C# and C++.
Q10) Write the advantages and disadvantages of object relational databases?
A10) Advantages of object relational database
The benefits of the Object Relational model are −
● Inheritance
The Object Relational data model makes it possible for its users to inherit structures, tables, etc. so that their functionality can be expanded. Inherited objects include new attributes as well as the attributes that were inherited.
● Complex data type
Using existing data types, complex data types can be created. This is useful as complex data types allow better data manipulation in the Object Relational Data Model.
● Extensibility
In the Object relational data model, the functionality of the framework can be expanded. Using complex data types, as well as advanced object-oriented model principles such as inheritance, this can be accomplished.
Disadvantages
At times, the object relational data model can become very complex and difficult to manage since it is a mixture of the object-oriented data model and the relationship data model and uses the features of both of them.
Q11) Explain object relational mapping?
A11) Without having to write SQL queries, an object-relational mapper creates an object-oriented layer between relational databases and object-oriented programming languages. It standardizes interfaces, which reduces boilerplate and speeds up development.
Object-oriented programming has a large number of states and codes in a difficult-to-understand-and-interpret manner. ORMs take this information and turn it into a structured map that developers may use to comprehend the database's structure. The mapping explains the relationships between items and tables.
ORMs employ this information to transform data across tables and generate SQL code for inserting, updating, creating, and deleting data in a relational database in response to changes made by the application to the data object. The ORM mapping will take care of the application's data needs once it's written, and you won't have to write any additional low-level code.
ORM has three techniques to address the object code and relational database mismatch: bottom up, top down, and meet in the middle. Each strategy has its own set of advantages and disadvantages. Developers must fully comprehend the environment and design requirements before selecting the finest software solution.
ORM's advantages include, in addition to the data access technique:
● Because it automates object-to-table and table-to-object conversion, it simplifies development and lowers maintenance expenses.
● In comparison to embedded SQL and handwritten stored procedures, there is less code.
● In the application tier, transparent object caching improves system speed.
● An efficient solution that makes it faster and easier to maintain an application.
The rise of ORM in numerous application development has sparked debate among specialists. The performance of ORM is a major concern, and stored procedures may be a better option. Furthermore, in some cases, ORM dependency might lead to poorly built databases.
Types of ORM
The active record pattern and the data-mapper pattern are the two methodologies used by ORMs.
Active record pattern
This method organizes data within the code's object structure. Within your computer code, you manage data using classes and structures. Because the database structure is intimately linked to the code, it is difficult to remove the database and migrate it to a different application using this method.
Data-mapper patterns
The data-mapper pattern tries to separate the database from the business logic in the objects. This split makes it simpler to switch databases while maintaining the same programming logic.
Q12) Write the advantages of ORM?
A12) Advantages
ORM technologies are popular among OOP programmers because they reduce the amount of SQL expertise needed to link a database to a program. ORMs also produce SQL code for you, allowing you to concentrate on creating business logic. Using object-related mappers to manage the interface between applications and databases has four major advantages.
● Productivity
Data-access code takes time to write and adds little benefit to the application's functionality. It's essentially the code's plumbing. Using a technology like an ORM that creates data-access code automatically saves a lot of effort that isn't adding value to the application. In some circumstances, the ORM can write the entirety of the application's data-access code. The ORM can also assist you in keeping track of database changes, making future debugging and updates easier.
● Application design
Design patterns are used in a well-written ORM to push you to utilize best practices for application design. You don't need to develop a flawless database schema in advance if you use an ORM to manage the data interface. You will be able to simply alter the current interface. You may also switch out data for different applications by separating the database table from the programming code.
● Code reuse
Creating a class library to generate a second dynamic-link library is one technique to reuse data (DLL). You don't have to replicate the data-access code when creating a new application.
● Reduced testing
You don't have to spend as much time testing the data-access code because the ORM generates well-tested code. You can concentrate on testing the business logic and code instead.
Q13) What are the disadvantages of ORM?
A13) Disadvantages
ORMs are a great tool for a lot of things, but there are a few limitations to utilizing them for data-access apps, according to several developers. The problems appear to be related to the application's complexity. A high level of abstraction aids the development process in basic applications. When the applications are complicated, however, abstraction hides many of the specifics that are required to address data-related difficulties.
● Performance
The extra code generated by the ORM is a typical gripe among OOP developers. The extra code slows down the application and makes it more difficult to maintain. A well-designed ORM should be capable of producing high-quality code without slowing down the application.
● Need to Know SQL
High-level abstractions don't always result in the optimal SQL code, and developers can't always rely on the ORM. You'll still need to know SQL and the ORM's produced syntax.
● Poor Mapping
ORMs can occasionally result in erroneous mappings between data tables and objects. These issues might cause application issues and can be difficult to spot. Even though business applications rarely have many one-to-one relationships, ORMs encourage one-to-one mapping.
● Effects on Schema and Migrations
It's generally difficult to improve data structures when the ORM layer is poorly developed. It can often limit your selections, and your options may be limited depending on the ORM. If your ORM doesn't support migrations, writing migrations in OOP is more difficult than writing migration code in SQL. A well-written ORM will offer features to make database migrations easier in the future.
Q14) Write the difference between geometric and geography data?
A14) Difference between geometric data and geography data
Geometric | Geographic |
The connecting edge between two vertices in a geometry type is a straight line. | The connecting edge between two vertices in a geography type is a short great elliptic arc between the two vertices. A great ellipse is the intersection of the ellipsoid with a plane through its center and a great elliptic arc is an arc segment on the great ellipse. |
Circular arc segments for geometry types are defined in the XY Cartesian coordinate plane (Z values are ignored). | Circular arc segments for geography types are defined by curve segments on a reference sphere. Any parallel on the reference sphere can be defined by two complementary circular arcs where the points for both arcs have a constant latitude angle. |
In the planar, or flat-earth, system, measurements of distances and areas are given in the same unit of measurement as coordinates. Using the geometry data type, the distance between (1, 4) and (4, 8) is 5 units, regardless of the units used. | In the ellipsoidal, or round-earth, system, coordinates are given in degrees of latitude and longitude. However, the lengths and areas are usually measured in meters and square meters, though the measurement may depend on the spatial reference identifier (SRID) of the geography instance. The most common unit of measurement for the geography data type is meters. |
In the planar system, the ring orientation of a polygon is not an important factor. For example, a polygon described b ((0, 0), (5, 5), (0, 10), (-5, 5), (0, 0)) is the same as a polygon described by ((0, 0), (-5, 5), (0, 10), (5, 5), (0, 0)). The OGC Simple Features for SQL Specification does not dictate a ring ordering, and SQL Server does not enforce ring ordering. | In an ellipsoidal system, a polygon has no meaning, or is ambiguous, without an orientation. As an example, does a ring around the equator describe the northern or southern hemisphere? If the geography data type is used to store the spatial instance, the orientation of the ring must be specified and accurately describe the location of the instance. The interior of the polygon in an ellipsoidal system is defined by the left-hand rule. |