A major feature of a database system is to provide users with an abstract view of data i.e. the system hides certain details of how data is stored and maintained.
1) Data Abstraction
Data abstraction is the property of showing only the necessary details to a user and hides the rest of the details from that user. Since many database system users are not computer trained, developers hide the complexity from users through several levels of abstraction, to simplify user’s interactions with the system.
- Physical level – This level describes how data is actually stored in the database.
- Logical level – This level what data are stored in the database and what relationship exist among those data. The entire database is described to a community of users. The logical level of abstraction is used by Database Administrators (DBA) who must decide what information is to be stored in the database. One of the main reasons for using DBMS’s is to have central control of both the data and the programs that access those data. A person who has such central control over the system is called a Database Administrator (DBA).
- View level – This level describes only part of the entire database that a particular user group is interestedin and hides the rest of the database from that user group. The system may provide many views for the same database.
The inter-relationship between the three levels is as shown below:
2) Instances and Schemas
Databases change over time as information is inserted and deleted. The collection of information stored in the database at a particular moment of time is called an instance of the database. The overall design of the database is called the database schema. Schemas are not expected to change frequently.
3) Data independence
The ability to modify a schema definition in one level without affecting the schema definition in the next higher level is called data independence. There are two levels of data independence.
a) Physical data independence – It is the ability to change the physical schema without changing the logical schema. Modifications at the physical level are occasionally necessary to improve performance.
b) Logical data independence – It is the ability to modify the logical schema without changing the schema at the view level. Modifications at the logical level are necessary whenever the logical structure of the database is altered.
The concept of Keys in database:
A relation is defined as a set of tuples. By definition, all elements of a set are distinct; hence, all tuples in a relation must also be distinct. This means that no two tuples can have the same combination of values for all their attributes. The various keys used in databses are:
- Superkey – A superkey, SK specifies a uniqueness constraint that no two distinct tuples in any state r of R can have the same value for SK i.e. a superkey specifies the constraint that two distinct tuples in any state of the relation cannot have identical values for (all) the attributes in the key. Every relation has at least one default superkey – the set of all its attributes. A superkey can have redundant attributes
- Key – A key, K of a relation schema R is a superkey of R with the additional property that removing any attribute A from K leaves a set of attributes K that is not a superkey of R any more. Hence, a key satisfies two constraints: 1) Two distinct tuples in any state of the relation cannot have identical values for (all) the attributes in the key and, 2) It is a minimal superkey i.e. a superkey from which we cannot remove any attributes and still have the uniqueness constraint in condition 1 hold.
- Candidate Key– A relation schema may have more than one key. In this case, each of the keys is called a candidate key. For example, in the figure below, the CAR relation has two candidate keys: LicenseNumber and EngineSerialNumber
- Primary Key– One of the candidate keys as the primary key of the relation. This is the candidate key whose values are used to identify tuples in the relation.
- Foreign Key – It is an attribute (or collection of attributes) in a relation (referencing relation) that can be used as a key (that refers) to another relation (referenced relation). Foreign keys link tables together to form an integrated database. The columns in the referencing table must be the primary key or other candidate key in the referenced table.