Você está na página 1de 6

BtCS-06 1. TYPES OF KEYS IN RDBMS. WHAT IS RDBMS? ADVANTAGE & DISADVANTAGE OF DBMS. ANS.

TYPES OF KEYS IN RDBMS:I) Super Key An attribute or a combination of attribute that is used to identify the records uniquely is known as Super Key. A table can have many Super Keys. E.g. of Super Key 1. ID 2. ID, Name 3. ID, Address 4. ID, Department_ID 5. ID, Salary 6. Name, Address 7. Name, Address, Department_ID So on as any combination which can identify the records uniquely will be a Super Key. (II) Candidate Key It can be defined as minimal Super Key or irreducible Super Key. In other words an attribute or a combination of attribute that identifies the record uniquely but none of its proper subsets can identify the records uniquely. E.g. of Candidate Key 1. Code 2. Name, Address For above table we have only two Candidate Keys (i.e. Irreducible Super Key) used to identify the records from the table uniquely. Code Key can identify the record uniquely and similarly combination of Name and Address can identify the record uniquely, but neither Name nor Address can be used to identify the records uniquely as it might be possible that we have two employees with similar name or two employees from the same house. (III) Primary Key A Candidate Key that is used by the database designer for unique identification of each row in a table is known as Primary Key. A Primary Key can consist of one or more attributes of a table. E.g. of Primary Key - Database designer can use one of the Candidate Key as a Primary Key. In this case we have Code and Name, Address as Candidate Key, we will consider Code Key as a Primary Key as the other key is the combination of more than one attribute. (IV) Foreign Key A foreign key is an attribute or combination of attribute in one base table that points to the candidate key (generally it is the primary key) of another table. The purpose of the foreign key is to ensure referential integrity of the data i.e. only values that are supposed to appear in the database are permitted.

E.g. of Foreign Key Let consider we have another table i.e. Department Table with Attributes Department_ID, Department_Name, Manager_ID, Location_ID with Department_ID as an Primary Key. Now the Department_ID attribute of Employee Table (dependent or child table) can be defined as the Foreign Key as it can reference to the Department_ID attribute of the Departments table (the referenced or parent table), a Foreign Key value must match an existing value in the parent table or be NULL. (V) Composite Key If we use multiple attributes to create a Primary Key then that Primary Key is called Composite Key (also called a Compound Key or Concatenated Key). E.g. of Composite Key, if we have used Name, Address as a Primary Key then it will be our Composite Key. (VI) Alternate Key Alternate Key can be any of the Candidate Keys except for the Primary Key. E.g. of Alternate Key is Name, Address as it is the only other Candidate Key which is not a Primary Key. (VII) Secondary Key The attributes that are not even the Super Key but can be still used for identification of records (not unique) are known as Secondary Key. E.g. of Secondary Key can be Name, Address, Salary, Department_ID etc. as they can identify the records but they might not be unique. A surrogate key in a database is a unique identifier for either an entity in the modeled world or an object in the database. The surrogate key is not derived from application data.

WHAT IS RDBMS
RDBMS stands for Relational Database Management System. RDBMS data is structured in database tables, fields and records. Each RDBMS table consists of database table rows. Each database table row consists of one or more database table fields. RDBMS store the data into collection of tables, which might be related by common fields (database table columns). RDBMS also provide relational operators to manipulate the data stored into the database tables. Most RDBMS use SQL as database query language. Edgar Codd introduced the relational database model. Many modern DBMS do not conform to the Codds definition of a RDBMS, but nonetheless they are still considered to be RDBMS. The most popular RDBMS are MS SQL Server, DB2, Oracle and MySQL.

ADVANTAGE OF DBMS
The advantages of DBMS

1. 2. 3. 4.

It represents complex relationships among different data items. Keeps a tight control on data redundancy. Enforces user defined rules to ensure the integrity of data in a table form. Maintains data dictionary for the storage of information pertaining to data fields and data manipulation.

5. 6. 7.
8.

Ensures that data can be shared across all applications. Enforces data access authorization. Has an automatic intelligent backup and recovery procedure of data. Has different interfaces through which users can manipulate data.

There are three main features of a database management system that make it attractive to use a DBMS in preference to more conventional software. These features are centralized data management, data independence, and systems integration. In a database system, the data is managed by the DBMS and all access to the data is through the DBMS providing a key to effective data processing. This contrasts with conventional data processing systems where each application program has direct access to the data it reads or manipulates. In a conventional DP system, an organization is likely to have several files of related data that are processed by several different application programs. In the conventional data processing application programs, the programs usually are based on a considerable knowledge of data structure and format. In such environment any change of data structure or format would require appropriate changes to the application programs. These changes could be as small as the following: 1. 2. 3. 4. Coding of some field is changed. For example, a null value that was coded as -1 is now coded as -9999. A new field is added to the records. The length of one of the fields is changed. For example, the maximum number of digits in a telephone number field or a postcode field needs to be changed. The field on which the file is sorted is changed.

If some major changes were to be made to the data, the application programs may need to be rewritten. In a database system, the database management system provides the interface between the application programs and the data. When changes are made to the data representation, the metadata maintained by the DBMS is changed but the DBMS continues to provide data to application programs in the previously used way. The DBMS handles the task of transformation of data wherever necessary. This independence between the programs and the data is called data independence. Data independence is important because every time some change needs to be made to the data structure, the programs that were being used before the change would continue to work. To provide a high degree of data independence, a DBMS must include a sophisticated metadata management system. In DBMS, all files are integrated into one system thus reducing redundancies and making data management more efficient. In addition, DBMS provides centralized control of the operational data. Some of the advantages of data independence, integration and centralized control are: 1. Redundancies and inconsistencies can be reduced In conventional data systems, an organisation often builds a collection of application programs often created by different programmers and requiring different components of the operational data of the organisation. The data in conventional data systems is often not centralised. Some applications may require data to be combined from several systems. These several systems could well have data that is redundant as well as inconsistent (that is, different copies of the same data may have different values). Data inconsistencies are often encoutered in everyday life. For example, we have all come across situations when a new address is communicated to an organisation that we deal with (e.g. a bank, or Telecom, or a gas company), we find that some of the communications from that organisation are recived at the new address while others continue to be mailed to the old address. Combining all the data in a database would involve reduction in redundancy as well as inconsistency. It also is likely to reduce the costs for collection, storage and updating of data. 2. Better service to the Users A DBMS is often used to provide better service to the users. In conventional systems, availability of information is often poor since it normally is difficult to obtain information that the existing systems were not designed for. Once several conventional systems are combined to form one

3.

4.

5.

6.

7.

8.

9.

centralised data base, the availability of information and its up-to-dateness is likely to improve since the data can now be shared and the DBMS makes it easy to respond to unforseen information requests. Centralizing the data in a database also often means that users can obtain new and combined information that would have been impossible to obtain otherwise. Also, use of a DBMS should allow users that do not know programming to interact with the data more easily. The ability to quickly obtain new and combined information is becoming increasingly important in an environment where various levels of governments are requiring organisations to provide more and more information about their activities. An organisation running a conventional data processing system would require new programs to be written (or the information compiled manually) to meet every new demand. Flexibility of the system is improved Changes are often necessary to the contents of data stored in any system. These changes are more easily made in a database than in a conventional system in that these changes do not need to have any impact on application programs. Cost of developing and maintaining systems is lower As noted earlier, it is much easier to respond to unforseen requests when the data is centralized in a database than when it is stored in conventional file systems. Although the initial cost of setting up of a database can be large, one normally expects the overall cost of setting up a database and developing and maintaining application programs to be lower than for similar service using conventional systems since the productivity of programmers can be substantially higher in using non-procedural languages that have been developed with modern DBMS than using procedural languages. Standards can be enforced Since all access to the database must be through the DBMS, standards are easier to enforce. Standards may relate to the naming of the data, the format of the data, the structure of the data etc. Security can be improved In conventional systems, applications are developed in an ad hoc manner. Often different system of an organisation would access different components of the operational data. In such an environment, enforcing security can be quite difficult. Setting up of a database makes it easier to enforce security restrictions since the data is now centralized. It is easier to control who has access to what parts of the database. However, setting up a database can also make it easier for a determined person to breach security. We will discuss this in the next section. Integrity can be improved Since the data of the organization using a database approach is centralized and would be used by a number of users at a time, it is essential to enforce integrity controls. Integrity may be compromised in many ways. For example, someone may make a mistake in data input and the salary of a full-time employee may be input as $4,000 rather than $40,000. A student may be shown to have borrowed books but has no enrolment. Salary of a staff member in one department may be coming out of the budget of another department. If a number of users are allowed to update the same data item at the same time, there is a possiblity that the result of the updates is not quite what was intended. For example, in an airline DBMS we could have a situation where the number of bookings made is larger than the capacity of the aircraft that is to be used for the flight. Controls therefore must be introduced to prevent such errors to occur because of concurrent updating activities. However, since all data is stored only once, it is often easier to maintain integrity than in conventional systems. Enterprise requirements can be identified All enterprises have sections and departments and each of these units often consider the work of their unit as the most important and therefore consider their needs as the most important. Once a database has been set up with centralised control, it will be necessary to identify enterprise requirements and to balance the needs of competing units. It may become necessary to ignore some requests for information if they conflict with higher priority needs of the enterprise. Data model must be developed Perhaps the most imporrant advantage of setting up a database system is the requirement that

an overall data model for the enterprise be built. In conventional systems, it is more likely that files will be designed as needs of particular applications demand. The overall view is often not considered. Building an overall view of the enterprise data, although often an expensive exercise, is usually very cost-effective in the long term.

Advantages

Reduced data redundancy Reduced updating errors and increased consistency Greater data integrity and independence from applications programs Improved data access to users through use of host and query languages Improved data security Reduced data entry, storage, and retrieval costs Facilitated development of new applications program

Disadvantages Database systems are complex, difficult, and time-consuming to design Substantial hardware and software start-up costs Damage to database affects virtually all applications programs Extensive conversion costs in moving form a file-based system to a database system Initial training required for all programmers and users

2.

DBTG SET

ANS. he DBTG model uses two different data structures to represent the database entities and
relationships between the entities, namely record type and set type. A record type is used to represent an entity type. It is made up of a number of data items that represent the attributes of the entity. A set is used to represent a directed relationship between two record types, the so-called owner record type, and the member record type. The set type, like the record type, is named and specifies that there is a one-to-many relationship (I:M) between the owner and member record types. The set type can have more than one re-cord type as its member, but only one record type is allowed to be the owner in a given set type. A database could have one or more occurrences of each of its record and set types. An occurrence of a set type consists of an occurrence of each of its record and set types. An occurrence of a set type consists of an occurrence of the owner record type and any number of occurrences of each of its member record types. A record type cannot be a member of two distinct occurrences of the same set type. Bachman introduced a graphical means called a data structure diagram to denote the logical relationship implied by the set. Here a labelled rectangle represents the corresponding entity or record type. An arrow that connects two labelled rectangles represents a set type. The arrow direction is from the owner record type to the member record type. Figure shows two record types (DEPARTMENT and ENTLOYEE) and the set type DEPIT-EMP, with DEPARTMENT as the owner record type and EMPLOYEE as the member record type.

Figure 20 : A DBTG set The data structure diagrams have been extended to include field names in the record type rectangle, and the arrow is used to clearly identify the data fields involved in the set association. A one-to-many (I:M) relationship is shown by a set arrow that starts from the owner field in the owner record type. The arrow points to the member field within the member record type. The fields that support the relationship are clearly identified. A logical record type with the same name represents each entity type in an E-R diagram. Data fields of the record represent the attributes of the entity. We use the term logical record to indicate that the actual implementation may be quite different. The conversion of the E-R diagram into a network database consists of converting each I:M binary relationship into a set (a 1:1 binary relationship being a special case of a 1:M relationship). If there is a 1:M binary relationship R1 from entity type E1 to entity type E2,

Figure 21 : Conversion of an M:N relationship into two 1:M DBTG sets Then the binary relationship is represented by a set an instance of this would be S1 with an instance of the record type corresponding to entity E1 as the owner and one or more instances of the record type corresponding to entity E2 as the member. If a relationship has attributes, unless the attributes can be assigned to the member record type, they have to be maintained in a separate logical record type created for this purpose. The introduction of this additional record type requires that the original set be converted into two symmetrical sets, with the record corresponding to the attributes of the relationship as the member in both the sets and the records corresponding to the entities as the owners. Each many-to-many relationship is handled by introducing a new record type to represent the relationship wherein the attributes, if any, of the relationship are stored. We then create two symmetrical I:M sets with the member in each of the sets being the newly introduced record type. The conversion of a many-to-many relationship into two one-to-many sets using a common member record type is shown in figure 21. In the network model, the relationships as well as the navigation through the database are predefined at database creation time.

Você também pode gostar