Data is collection of facts and figures anything visible to us or beyond our visualisation.
Database is a collection of related data, stored so that it is available to all different users for different purposes.
Database management system is a collection of programs that enables users to create and maintain a database.
Advantages of using DBMS:
- Control redundancy.
- Restricted unauthorized access.
- Provide backup and recovery.
- It keep information upto date.
Schemas and Instances
Description of database called DB schema, specified during DB design and not do change frequently.
The data in the DB at a particular moment in a time is called instance in the DB.
3 Schema Architecture
Its a tool with which the user can visualise the scheme level in the DB.
Goal: seperate user application and physical DB.
Internal level: describe physical storage structure access path.
- Describe the structure of whole DB for community of user.
- Hides detail of physical storage structure and concentrates on describing entities, data types etc.
- Includes external schema and user views.
- Describe part of DB for particular user.
Normalization is used for mainly two purpose:
- Eliminating reduntant(useless) data.
- Ensuring data dependencies make sense i.e data is logically stored.
Normalization rule are divided into following normal form.
- First Normal Form
- Second Normal Form
- Third Normal Form
For details of these rule refer to this link.
Concept of keys in DB
Keys are very important part of Relational database. They are used to establish and identify relation between tables. They also ensure that each record within a table can be uniquely identified by combination of one or more fields within a table.
- Set of fields from which primary key can be selected.
- It is an attribute or set of attribute that can act as a primary key for a table to uniquely identify each record in that table.
- Its a key that uniquely identify each record in a table.
- It is a candidate key that is most appropriate to become main key of the table.
NOTE: Difference between primary & unique key
- Primary key- can never be null.
- Unique key- can be null.
- If we add additional attributes to a primary key the resulting combination would still uniquely identify an instance of entity set is Super key.
- It is a superset of Candidate key.
- Key that consist of two or more attributes that uniquely identify an entity occurance is called Composite key.
- But any attribute that makes up the Composite key is not a simple key in its own.
Secondary or Alternative key:
- The candidate key which are not selected for primary key.
- Example- university_id : Primary key ; college_id: Secondary key