There are several architectural models for parallel machines or systems. In following figure, M denotes memory, P denotes a processor, and disks areshown as cylinders.
- Shared memory : All the processors share a common memory (Figure a).
- Shared disk : All the processors share a common set of disks (Figure b). Shared-disk systems are sometimes called clusters.
- Shared nothing : The processors share neither a common memory nor common disk (Figure c).
- Hierarchical : This model is a hybrid of the preceding three architectures (Figure d).
Techniques used to speed up transaction processing on data-serrver systems, such as data and lock caching and lock de-escalation. These techniques can also be used is shared-disk parallel databases as well as in shared-nothing parallel databases.
Shared Memory
- In a shared-memory architecture, the processors and disks have access to a common memory, typically via a bus or through an interconnection network.
- Benefit of using shared memory is extreme efficient communication between processors - data in shared memory can be accessed by any processor without being moved with software.
- A processor can send messages to other processors much faster by using memory writes than by sending messages through communication medium.
- There is downside of shared memory as well. The architecture is not scalable beyond 32 or 64 processors. Reason behind this downside is bus or the interconnection network becomes the bottleneck. Adding more processors will make processors spend most of their time in waiting for their turn on the bus to access memory.
- Shared memory architectures usually have large memory caches at each processor, so that referencing of the shared memory is avoided whenever possible.
- Moreover, caches need to be coherent, that is , if a processor performs a write to a memory location, the data in that memory location should be either updated at or removed from any processor where the data is cached.
Shared Disk
- In the shared-disk model, all processors can access all disks directly via an interconnection network, but the processors have private memories.
- Shared disk has two advantages over shared memory. First is, since each processor has its own memory, the memory bus is not a bottleneck. Second is, it offers a cheap way to provide a degree of fault tolerance.
- Fault tolerance : If a processor ( or its memory) fails, the other processor can take over its tasks, since the database is resident on disks that are accessible from all processors.
- The main problem with shared disk system is again scalability. Although the memory bus is no longer a bottleneck, the interconnection to the disk subsystem is now a bottleneck.
- Compared to share memory systems, shared disk systems can scale to a somewhat larger number of processors, but communication across processors is slower , since it has to go through a communication network.
Shared nothing
- In shared nothing system, each node of the machine consists of a processor, memory and one or more disks. The processors at one node may communicate with another processor at another node by a high speed interconnection network.
- A node function as a serverfor the data on the disk.
- Moreover, the interconnection networks for shared nothing systems are usually designed to be scalable, so that their transmission capacity increases as more nodes are added.
- Consequently, shared nothing architectures are more scalable and can easily support a large number of processors.
- Main drawback of shared nothing systems are the costs of communication and of nonlocal disk access, which are higher than in a shared memory or shared disk architecture since sending data involves software interaction at both ends.
- Teradata database and Grace and the Gamma research prototypes are shared nothing architectures.
Hierarchical
- The hierarchical architecture comes with characteristics of shared memory, shared disk and shred nothing architectures. At the top level, the system consists of nodes connected by an interconnection network, and do not share disks or memory woth one another.
- Thus, the top level is a shared nothing architecture.
- Attempts to reduce the complexity of programming such systems have yielded distributed virtual-memory architectures, where logically there is a single shared memory, the memory mapping hardware coupled with system software, allows each processor to view the disjoint memories as a single virtual memory,
- Such architectures are also referred to as a nonuniform memory architecture (NUMA).
Underlying the structure of a database is the data model : a collection of conceptual tools for describing data, data relationships, data semantics, and consistency constraints. To illustrate the concept of data model, two of the data models are outlined below. One data model is entity-relationship model and the other is relational model. Both provides a way to describe the design of a database at the logical level.
The Entity-Relationship Model
-
The Entity-relationship (E-R) data model is based on a perception that it consists of a collection of basic objects, called as entities , and of relationships among these objects (or entities).
-
An entity is a "thing" or "object" in the real world that is distinguishable from other objects. For example, each person is an entity, and bank accounts can be considered as entities.
-
In databases, entities are described by a set of attributes. For example, the attributes account-number and balance may describe one particular account in a bank and they form attributes of the account entity set. Similarly, attributes customer-name, customer-street address and customer-city may describe a customer entity.
-
An extra attribute customer-id is used to uniquely identify customers. A unique customer identifier must be assigned to each customer. In the U.S., many enterprises use the social security number of a person ( a unique number the U.S. government assigns to every person in the United States) as a customer identifier.
-
A relationship is an association among several entities. For example, a depositor relationship associates a customer with each account that he or she has. The set of all entities of the same type and the set of all relationships of the same type are termed as entity set and relationship set, respectively.
- The overall logical structure of a database can be expressed graphically by an E-R diagram, which is built up from the components like
- Rectangles, which represent entity sets
- Ellipses, which represent attributes
- Diamonds, which represent relationships among entity sets
- Lines, which links attributes to entity sets and entity sets to relationships
- Each component is labeled with the entity or relationship that it represents.
As an illustration, consider a part of database banking system consisting of customers and of the accounts that these customers have. Following figure shows the corresponding E-R diagram. The E-R diagram indicates that there aretwo entity sets, customer and account with attributes as outlined earlier. The diagram also shows a relationship depositor between customer and account.
Relational Model
- The relational model uses a collections of tables to represent both data and the relationships among those data. Each table has multiple columns, andeach column has a unique name. Following figure represents a sample relational database comprising three tables: one shows details of bank customers, the second shows accounts, and the third shows which account belong to which customers.
- The first table, the customer table, shows, for example, that the customer identified by customer-id 192-83-7465 is named Johnson and lives at 12 Alma St. in Palo Alto.
- The second table, account, shows, for example, that account A-101 hasa balance of $500, and A-201 has a balance of $900.
- The third table shows which accounts belong to which customers. For example, account number A-101 belongs to the customer whose customer-id is 192-83-7465, namely Johnson, and customers 192-83-7465 (Johnson) and 019-28-3746 (Smith) share account number A-201.
- The relational model is an example of a record-based model.Record-based models are so named because the database is structured in fixed-format records of several types. Each table contains records of a particular type. Each record type defines fixed number of fields, or attributes. The columns of the table correspond to the attributes of the record type.
- The relational model is the most widely used data model, and a vast majority of current database systems are based on the relational model.
- The relational model is at a lower level of abstraction than the E-R model. Database designs are often carried out in E-R model, and then translated to the relational model.
There are also other data models like Object-oriented data model, Object-relational data model, network data model and hierarchical data model.
SQL is a standard language for accessing and manipulating databases. SQL is an abbreviation for Structured Query Language. Earlier, SQL was known as SEQUEL. SQL allows you to create simple as well as very complex database queries that are fired or executed against databases to deal with data present in databases. Dealing might be retrieving values from databases, inserting values into databases, modifying data, etc. To store any sort of data in databases, firstly, you need to create tables and declare its fields. It is mandatory to declare atleast one field in order to store values under that field.
There are several commands in SQL which are required to deal with tables created in databases and with its values. These are,
- CREATE
- SELECT
- UPDATE
- DELETE
- INSERT INTO
These are very basic commands. As soon as we log in into database, first we need to create a database. Here, database is not the database like SQL. Here, creating a new database means allocating or creating part of database by giving name as desired. New database can be created by using following SQL query.
CREATE DATABASE UserDatabase
After writing above query, just select the whole query and execute. As this query gets executed, a database named "UserDatabase" will be created in your database (MySQL or Oracle). Then next step is to activate user created database. For that, You need to execute following query.
USE DATABASE UserDatabase
After executing this query, database named UserDatabase will get activated. And now, you can proceed by creating tables, inserting values in it.
To create a table, you need to decide the name for it and this name should match the requirements of your problem. This name should not be weird. It should be meaningful and always a noun. Also, you need to decide fields in the tables and these names must be meaningful. Here, table "Orders" is created with fields as Order_Id, OrderName. Data types for these fields should be same as required.
CREATE TABLE Orders ( Order_Id int, OrderName varchar (255) )
After executing above query your table Orders with fields Order_Id and OrderName will be created. Now, next step is to insert values or records in table. In SQL, each complete row with values for all of the fields is known as a Record.
INSERT INTO Orders VALUES ( 1, 'Dispatch')
After executing above query, one record with values as 1 and Dispatch will be created in table Orders. Similarly, you can use above query with different values to insert records into table.
Now, to see whether values are properly inserted into table or not, following query needs to be used.
SELECT * FROM Orders
After execution of above query, all records will get displayed. If you want to see the record of one particular record, following query needs to be used.
SELECT * from Orders WHERE Order_Id = 1
Here, WHERE is a clause which is used at the time of condition. When above query is executed, whole record with Order_Id as "1" is only displayed.
If you want to see values of only one field, then use following query,
SELECT Order_Id from Orders
After executing above query, values under Order_Id field will only be displayed. Similarly, we can modify any of the records present in the table. For this, we need to use following query.
UPDATE Orders SET Order_Id = 2 WHERE OrderName = 'Dispatch'
After executing this query, record with OrderName as "Dispatch" gets modified or updated with Order_Id as "2". Now, if you wish to delete any one particular record from a table then DELETE command needs to be used and that too, in the following manner.
DELETE FROM Orders where Order_Id = 1
With this query, you will be able to delete record from your table. Now, finally, if you wish to delete table as a whole, you don't need to use DELETE command but you will be required to use DROP command.
DROP TABLE Orders
After execution of above query, table with name as "Orders" will be deleted. similarly, you can use DROP command to delete database as well.
DROP DATABASE UserDatabase
So, in this way, you can deal with database and its data by using above listed queries.