RDBMS and Relational Model
RDBMS
CRUD - create, read, update and delete
Data - any information which can help you to make a decision or can help to make a choice. Data is of different type (Notes, Phone number, to-do list, pics etc.)
Some of the application to read a data:
Plain text reader, excel, access and other applications.
Drawbacks of Excel which database overcome:
- Inefficiency to access data - If need to access a data to specific id then as need to iterate for informaiton, hence timecomplexity is O(n)
- Data Integrity - Columns can have any kind of data even numeric column can have string data which is not right.
- Concurrency - Allowing multiple users to read data at a time form same file. Which should not interfere with requirements, and don't manipulate the data.
- Data Security - Only authorized users should be able to access the data. Hence we have management and rules for this security enforcement.
Scenario to understand need of database:
If dats is present in excel sheet then steps to find psp of students in excel as a programmer will be.
- Open/Read file
- Iterate fields and values for information
- extract psp data from relevent locations.
- calculate it for result.
TIme complexity for this task is: O(N). As we have to read each character of file for information identification and then to extract it for information computation.
So file system has drawbacks as we need to read entire file for information gathering and then can work on real task. Even a developer unintentionally can manupulate data which will lead to errors.
Drawbacks:
- Inefficient - As least T.C = O(n) and it can increase as well.
- Data integrity - we can have wrong data in wrong location or column as we don't restrict user to provide only specific type of data.
- Data is inaccurate
- We got text in numeric column. PSP column must have numeric data but received text data at row 4. As excel don't restrict user at time of uploading data. As we can't hard bound this rule to have only revelent data in revelent column.
- Concurrency - Simultaneous access of file. In short case when multiple people want to access same file at same time and want to modify data for their usage.
- As normal files don't have this rule to allow which user can write the data and who can overwrite it hence it is causing concurrency issue.
- Data security issue: As anyone can access data and can modify it.
Database:
Example based understanding.
As you can see from picture each catagory has certain rules to define nature of data which can reside in them.
- Army Base - only troops and vehicles or any other equipment which can work on ground and can use for war can stay in this category.
- Air Base - All things which can fly and can be used for war come under this category and those things can't go too much far away from ground or country region due to fuel issue.
- Navel base - All things which can swim and can be used for war or can carry things for war by using water as travel medium will come under this category.
So as you can see it has certain rules which will force users to put only relevent information to relevent location.
So all four drawbacks of file system is taken care by database so database is a management system which will help you to have rules implemented for data storage and usage by any user.
This mangement system is know an Database Management System( DBMS).
DBMS:
- A software system that allows to efficiently manage a database.
- DBMS allow operations:
- Create
- Read
- Update
- Delete
- Rule enforced by DBMS:
- Data integrity
- Security
- Concurrency
Types of Databases:
- Relational Database -
- Data is stored in form of tables
- Tables have relationship amoung them to provide relevent data for information. In short inter-related tables are used for data storage.
- Non -Relational Database -
- Son't store data in form of table.
- Store data in form of documents, key-value pairs, graphs etc.
Properties of RDBMS:
- Relational databases represent database as a collection of tables with each table storing information about something.
- Every row is unique. As you can see in above images each record is unique in a table. Reason if we have duplicate records then we will have ambiguity to update or to fetch data from table. As it will cause issue to uniquely identify the record in table for information manupulation or read. columns can have duplicate but entire record as a whole should not be duplicate.
- A column should have all values of same data type. As you can see in above attached tables screen shots.
- It can help us to hardbound columns to store specific data type data in a column.
- All values/cell should be atomic in nature. As you can see in below snapshot a cell can't have two values as it will lead to ambiguity.
- The sequence of column is not guaranteed by RDBMS. MySQL do preserve column order. You can mention any column name in any sequence and can put information in a table.
- insert into table column(a,b,c,d) values(e,r,f,g);
- insert into table column(b,a,c,d) values(e,r,f,g);
- The sequence of row is not guarenteed. It means even after inserting records in a database in specific order row can suffle there positions in database. MySQL so preserve row order.
MySQL preserve both column order and row order. But for RDBMS it is not manditory to preserve order or row and column.
- Name of every column has to be unique.
- in order to avoid ambiguity we need to have unique names of each columns and need to have unique record as well.
Keys:
Unique identifier for any record in a table.
Types of Keys:
- Super Keys
- Candidate Keys
- Primary Keys
- Composite Keys
- Foreign Keys
Super Keys:
It is a key which can help user to uniquely identify row in a table.
It uses a column / combination of columns to uniquely identify a row.
In case of super key redundant columns are allowed.
As you can see if you have id then all other columns are redundant.










Comments
Post a Comment