Sunday, 27 October 2013

The ER Model



In our previous sessions, we've been some what brief to the relational database models. Toady, we'll have an in detail examination of what is what. Basically, in R DBMS everything that is data before is now a relation. Hence, a relational database consists of relation aka tables which have rows and columns.

  • Rows are called Tuples.
  • Columns are called attributes.
  • Number of rows in a table constitute the cardinality.
  • Number of columns in a table constitute the arity.
  • The intersection of a row and a column is called a cell.
Hence, we work entirely on the cells, at each tuple of an attribute. the relational database was constructed based on a theory called the ER model. The ER model describes how a relation can be established, given a problem. The entities are the things that are under our examination. here we can assume an entity to be a table. An attribute describes the entity well. hence it is a description of the entity. we can assume this attribute to the columns of our table. A Relation is the thing that relates two entities: an intersection of two entities. We try to work out the model in our construction of a table. The model uses a diagrammatic approach for different cases of entities and attributes, and for a relation. The main elements of ER model are:

  • Entity
  • Attribute
  • Relation
Entity is represented by a rectangular box, an attribute by an ellipse and relationship is done by a Rhombus. A small example of ER model is discussed below:

Problem: a Student Joins in a College

Model:

There are principally 3 types of relationships, by their nature. They are:

  • One-to-One
  • One-to-Many/ Many-to-One
  • Many-to-Many
One to One relationship involves two entity relationship, One to Many involves more relations while many to many involves even more relations.

The Above problem can be modified to all the types like:

a Student Joins in a College (1-1)




many Students Join a College (m-1)



many Students Join many Colleges (m-m)




Another important element in the construction of a database, is the selection of the keys. A key is an attribute of a relation that uniquely identifies each tuple. For example if we take all the students information in a relation, then obviously student roll number or his admission number or his registration number will be unique of each student. hence they are all alternatives for the key.

One such attribute selected is called a Primary Key. If two relation have a common key that uniquely identifies its Tuples, is called a foreign key. This is similar to a Parent-Child relationship in class and objects concept: inheritance. If two or more keys are combined in case of forming a single key for a table, its called  a composite key. Hence there are:

  • Primary Key
  • Foreign Key
  • Composite Key
  • Candidate Key
in a table. The ER model of a relation is mapped in order to construct a database table. Hence we involve the following steps in the construction of a database:

  • Referring the Problem
  • Identifying the Entities, attributes and Relations
  • Framing a model for the problem
  • Mapping the model for our database table.

Relational Database Management Systems


We've seen one of the factors that throw a great impact on the efficiency of data and types of database management schemes present in the development and manipulation of an efficient database. One thing must be clear for you by this time that a database is simply a powerful storage than a Hard Disk, made so because of the management we have for it. DBMS is the software version of such management/ governing scheme. There are Some goals that an efficient DBMS must aim at:
  • Creation of a Database
  • Efficient Handling of manipulations like add, modify or delete on the data
  • Employ constraints for Database Security
Hence our DBMS must somehow satisfy these needs to have an efficient handling of data. One thing is that how much large the data may be, it must be stored such that the operations must be responded very quickly. For Example let us consider a reservation database, that handles the seats in a vehicle, a Bus say. If our database is so slow that each query takes considerable time in responding, passengers will sure have to struggle a lot. Because since the tickets are such a data which can't be shared, if a ticket is issued to two people, then we'll have a fight!!!

 Relational database solves such problems by employing table constructs on the data construction. The rows are all entirely data, and columns map to the owners or the identifier variables. The cell is an intersection of a row and a column. For example in the above figure, tutorial_id, title, company are the variables which hold the values below in the respective columns. In RDBMS, the table is a relation, a row and a column being the values of the relation. Here we need to know about two things about the entries in the table, they are 
  • Entity
  • Attribute
An Entity is the item being described in the table, and attribute being the values. Hence a table consists of Entities and attributes for the entities. A Relational Database is represented in the form of a relation between the attributes, the tables we generally speak about will be of the form

D(d1,d2,d3,.......dn) where d1, d2,... are all attributes which hold the column values.

Edgar F. Codd was the man behind the origin of a Relational Database Management Systems. He defined a relation as a one that satisfies 12 rules to be called so. We'll pause our discussion at this point and we'll discuss them in their full view next time...

Effect of Physical Media on Database Performance



In our previous discussions, we've seen things such as some typical fields of applications and Driving Force behind databases. You Can refer them Here.

Driving back to our King, like all other things we have some factors that influence the efficient utilization of a database. We'd now look at one of them: the Physical medium of Communication between the Database and the user. User can basically need to connect to a database before getting served by it. This connection can be in two ways materially, One is a Physical Link, and the other is a Virtual link.

A Physical Link is one connection that is visible and can be accessed physically  What i'm trying to say is that physical links are generally wired media. Our cables, are the best examples for it. 

A Virtual Link is one link that can't be viewed, its a software type. For example consider a Bluetooth connection between two devices, can we see the connection between them? We can't view them, but in the devices, the transfer can be witnessed. This is what, the most easy technique but at the same time, can't be wholly reliable. This is because that, the packets of data we share can't be traced once they are sent out of the device. Since the entire transmission is a medium independent, there's no scope for reliability. All we can see here is Hardware simplicity and fast access. WLAN, Bluetooth, etc., work on this technique. On the counter side, Ethernet is one best example of a wired type communication.

Actually, this topic needs more clarification because there are many related concepts of Data Communications with the discussed one above. I've related them to our discussion though they're not of great importance, because that we're here thinking about factors and the efficiency of a database depends on these links since these vary with the data rates.

Lets get back to our discussion, a Database is generally a collection of logically related data. The data are stored in database in the form of rows and columns of a table. Hence, a Database typically contains tables. The data are retrieved and manipulated based on these tables. 

Database management means use of tools in creating a database and maintaining it. There are two main ways in database management, the first one is the traditional management system. its called Files Management System, that uses programmatic way in creating and manipulating tables. Examples are the Files in C, C++ etc. but this is less user friendly and has its limitations too!

Hence we move on to an advanced method called Database Management Systems (DBMS). This uses the so discussed, Table format for a database management. This is widely used nowadays. In the DBMS, there are two more approaches, or the sub classes for it. They are the Relational DBMS and Object Oriented Databases.



DBMS:-
  •  RDBMS
  • OODBMS or ODBMS 
Relational Database is one which has a relation between the values of the table. The table is itself treated as a relation and we apply our relational mathematics on it. Object Oriented approach of the RDBMS is the next type called ODBMS. We'll have a detail account of these things and also beginning of the syntactical approach in our next discussion.

Database Systems










Previous Class: Here

I hope that you might have well understood the need of a database in present day applications.
we'll have a brief discussion on the applications of  database in various fields. Then we'll throw 
some flash on the underlying software that handles the king: Database.

1. As we've assumed previously, the main aim of database is to provide data sharing among several users. The aim of database has extended to such a manner that its now providing data sharing at a remote level. For example we know that we all access our mail accounts, send and receive mails. But we would wonder that these mails are not stored in our computer. right? We can access them anywhere and anytime, irrespective of the device we use: we can have the same mails accessed through our desktops and even from our mobiles. I'm just talking about the data we access, not how its being accessed. This example might confuse you a little bit because, database is generally a software driven Hardware. So we should talk about the software while mentioning the hardware too!

Well we'll leave the other things out of our scope here, such as the way in which we access them: data communications. here actually each person or the owner of mail has his mailbox or more naively, his very own virtual postbox in the database located somewhere else in this world. He'd log on to his account through some client address, and then checks his mails. Here the Database acts merely as a combo of a Huge Post Office and Post Box.

2. Internet, is all we're using somehow in our work. Even you are reading my bundles of notes through your internet right? but the internet is just a software: its a network. The driving force of Storage behind internet is the large use of Database Servers. A Server is a software and database is a storage. Together they provide the functionality of inter networking. The things you see on an internet are all simply web scripts: pages, bundles and bundles written in some language other than English :) These web pages are stored in the dedicated databases which are accessed remotely by the client systems when need some page to load. The browser acts as a dish in which your potato fry: i mean the pages are served by the server: in my sense database....
Just don't mingle Server and database here, we'll see that some other time.

3. Cloud, is the next level of database computing, in which the database is remotely accessed and offers several advantages like Single application being run on many systems etc.,

Now that you are aware of the application aspects of a database. if still the thing's not clear, just have a search on this thing. because applications include reservation systems, and many other online services, I've classified them in another form: the way in which a database functions.

Now we'll return to our concept of Database Systems. A System is generally a physical entity. But in this context we'll imagine this to be a Driving force. A Database is simply a Jumbo size storage disk for a Computer. But the thing's that even though we own a car for us, what's the driving force for it? Just don't say simply fuel, its the car keys!

In the same way, a Database needs a key to control it: a software that governs the functionality of the database. I just don't want to confuse and prolong it anymore, in the straight way, its the database system. Its a software installed to provide the functionality of a database. To be a successful thing, you must put some effort in your efficiency. In the same way, in order to build a successful database, we should concentrate on building an efficient software. 



We'll pause our story of King DB here, and next time we'll see DB System in detail and have a brief introdution of DBMS.

Introduction to Databases




Hello folks!

I'm sure its pretty well known to you that with the immense increase of technology and rapid growth in the utilization of services, the amount of data being produced has been terribly increasing. Its obvious that we need to save data after we are done working with it. this in the case of a single user. But in our scenario of data sharing between users: accessing of data by more that one individual is a bit to be thought. if the same situation occurs in an office where a single file has to be accessed by several users of several different systems, how can we satisfy their wish? we can't pull out the disk every time and pass it among them right! Or you may think to use removable storage in such cases, but what would you do when the data to be multiply accessed by people is terribly large? For example let us assume that all the files of a branch office has to be accessed by multiple users. How can that be satisfied with removable storage devices? Hence the expectations and the need broadens and the need for a stable storage that can satisfy our wish here arises. This Stable Storage is what we call as Database...

A Database is generally a Huge dump of data: a Collective Noun for Data we can say ( I'm not sure about Grammar here). This Huge dump of Data is present in some protected corner of the place and is wired to all other systems. These Systems connected to this Highest Degree Storage pass the wishes if the users to their master: the Database. The master in turn listens to their wishes and tries to quench their thirst: here data i mean. The wish sent by the user or issued b ya system is called a Request. The satisfaction provided by the King is called the Response. Hence accessing a Database involves series of Requests and Responses.

the accessing of database will be very frequent, so as the requests to the database. But the king can't delay and postpone these pleas, so as the judges do: every second counts. Hence a database must be maintained very efficiently so that it can process such requests very fast and save time. The schemes we apply on the database effects its performance. One such scheme is the type of structure we impose on the data to be stored in the database. I mean here, that the data structures we use in the database. Generally the databases are indexed and hashed to improve the efficiency of search and retrieval. Other Data Structures might also be used, we'll see that later.

Databases need not only Data structures to store and manipulate the data, they also need some mechanisms to preserve its stability while responding to several requests at a time. Here we get the name of a manager who looks after this duty. He's our DBMS...

                                                                    Data Base Management Systems

He looks after the stability of the database, and impose security and protection constraints to serve multiple usages.

I'll pause our discussion here....

we'll see the methods in which a database can maintain stability and how the database management provides this. Also we'll have a detail account on the structure of a database.