Explain The Role Of The Primary Key Computer Science Essay

Published: Last Edited:

This essay has been submitted by a student. This is not an example of the work written by our professional essay writers.

Database is a collection of information which is organized nicely so that can be easily managed, accessed, and updated the information and data. Database also can be classified according to the types of content such as bibliographic, full-text, numeric, and images.

Database in computing are sometimes classified according to their organizational approach. Relational database is the most popular approach, a tabular database which data is can be defined so that it can be accessed and reorganized in other different ways. Distributed database is a database that can be dispersed or replicated in a network with different points. An object-oriented programming database is balanced with the data defined in object classes and subclasses.

Computer databases normally contain combination of data records or files. Sales, transactions, product catalogs and inventories, and customer profiles are the example of the combination of data in computer databases. A database manager provides users the capabilities of controlling read and write access, specifying report generation, and analyzing usage.

3.0 Define question 1

In question 1, it is asking us to explain the role of the primary key and secondary key and to illustrate a diagram to explain it more briefly on how these keys are used within a database system. Then to explain it briefly will be using a diagram to do it as an example.

3.1 The role of Primary Key and Foreign key

The role of primary key and foreign key is a column or a set of column which are using to identify or access a row or a set of rows in a database is named a key. A combination of columns in a table that uniquely identify a row of the table is a primary key in a relational database. A field in a table that matches the primary key of another table is a foreign key in a relational database. Foreign key are used to cross reference tables. Their role are to differentiate from a table to another, primary key is representing a table that are the detail of minor attribute, foreign key is representing another table that are different detail which is also have the detail in primary attribute.

3.2 Primary Key

Primary key is a column or a combination of column that specifies defines a row in a table of a relational database. One primary key are the maximum in a database. Primary key enforces the reserved effective enforcement. So a column that is defined as the primary key cannot have ineffective values in it. Primary key can probably be a normal attribute in the table that is guaranteed to be special such as a social security number or it could be a unique value are generated by the database management system (DBMS) such as a Globally Unique Identifier (GUID) in Microsoft SQL Server. Primary keys are defined through the constraint in ANSI SQL Standard and also can be defined when creating the table. SQL is allowing the primary key to be made up of one or more columns and each column that is included in the primary key is secretly defined to be effective. But some database management systems (DBMS) require making the primary key column explicitly effective.

3.3 Foreign Key

Foreign key is a referential constraint between two tables. It identifies a column or a set of column in a table, called the referencing table that refers to a set of column in another table, called the references table. The foreign key in the referencing table must be the primary key or a candidate key in the referenced table so that it can be a referential constraint. A candidate key is a key to be used as the primary key, which is also means that is same meaning with primary key. Foreign keys are used to link the data or information across a few tables. Hence, the foreign key are cannot be containing the values that don't appear in the table that it refers to. With the provided of the foreign key in the reference can be used to link the information in a few tables and this is also would become essential with normalized databases. Formation associated with the other two tables, foreign key can only reference to the appearance in the column value or use of null values.

3.4 Difference between primary key and foreign key

Primary key is a set of column that are using unique way to identify a row in a table which the foreign key is a set of column that are referring to a primary key or a candidate key from another table. This is the difference between primary key and foreign key. If a method are to link information in several tables, which are foreign key mainly providing the method. Another difference is that a table can have a single primary key, but it can have multiple foreign keys that can reference different tables.

Student ID

First Name

Last Name

Course ID

















Course ID

Course Name








Short Course


Foreign Keys

Primary Keys


Figure 3.0 Primary Key and Foreign Key

This is the example of a table of primary key and foreign key are used. Primary keys are mandatory for every table each record must have a value for its primary key. While choosing a primary key from the pool of candidate keys always choose a single key over a composite keys always choose a single simple key over a composite key. Foreign key is generally a primary key from one table that appears in one another where the first table has a relationship to the second table. Which is also means that, if we had a table A with a primary key X that linked to a table B where X was a field in B, then X would be a foreign key in B.

4.0 Define question 2

In question 2, it is asking us to explain the characteristic and advantages of the following term of databases type. Relational database, object oriented database and object relational database are the type of databases also. Each of them are having different kind of characteristic and advantage, some are same also.

4.1 Relational database, Object oriented database, Object relational database

Relational database, Object oriented database and Object relational database are also include in databases. Relational database is a database system that based on the relational model. Object oriented database has the main feature of object-oriented databases is allowing the definition of objects, which are also different from normal database objects, reference the ability to develop a product. An object relational database is a database management system with that is similar to relational database except that it has an object oriented database model. This system supports objects, classes and inheritance in database schemas and query language.

4.2 Characteristic and Advantages of relational database

Relational databases are supporting an important concept of dynamic views. Which is in a relational database, a view is not the part of the physical schema, and it is a dynamic view. Furthermore changing the data in a table will alters the data depicted by the point of view. Views can be subset, join and simplify multiple relations, actively hide the complexity of the data and also reduces the data storage requirements.

Relational databases are also using SQL, which is means that SQL is an easy and human-readable language. SQL instructions are in the form of plain instructions, which is also can be put into the database for implementation. Most of the SQL standards are supported by database vendors. A rival technology of flat files supports a continuous storage of data and fails to provide the users with query options and search for the system. Which is also means that, relational databases are providing the users with simple operations to manipulate data in the databases and retrieve the data. In addition, relational databases are establishing defined a relationship between the tables, thus it is also giving their users a complete picture of the data stored.

Relational databases also have an excellent security. A relational database can supports the access permissions, which is allowing the databases administrator to implement need-based permissions to the access of the data in database tables. Relational databases are also supporting the concept of users and user rights, thus it is also meeting the security needs of databases. Relations are associated with special authority like create privileges, grant privileges, delete privileges, select and delete which authorize different users for corresponding operation on the database.

Their performance, power, and support also included as their advantages of relational databases, the support to new hardware technologies are also flexibility and also have a capacity to meet all the types of data needs. Relational databases are scalable and also providing the support for the implementation of distributed systems.

4.3 Characteristic and advantages of object oriented database

The main attribute of object oriented database is to provide data independent, consistent, secure, controlled and extensible data management services to support the object-oriented model. Big and complexion of data are can be handle more than relational database could not be.

Another characteristic of that object oriented database have which is joining of the object oriented programming with database technology, which is means that also provides an integrated application development system. Inheritances, data encapsulation, object identity, and polymorphism are the four different characteristic programming results in the object oriented database.

Inheritance allows one of the develop solutions to complex problems increasing by defining the new objects in the term of previous last defined objects. Hiding of the internal state of the objects is allowed by data encapsulation. While encapsulated objects are those objects that only can be assessed by their only methods instead of their internal states, there are having three kinds of encapsulated objects users and developers should be recognize. The first is a full encapsulation, which is all operations on objects are finish through sending message and method execution. Write encapsulation is where the internal state of the object visible only for reading operations is the second encapsulation. Partial encapsulation, which involves allowing direct access for the reading and writing for only a certain part of the internal state is the third encapsulation. Object identity is allowing objects of the database to be independent of each other. And also polymorphism and dynamic are binding to allow to define the operations for one of the object and then to share the specification of the operation with other objects. This allows users and programmers to compose an objects and providing solutions without having to write code that is specific to each other.

The advantages of the object oriented database are offering increased modeling power by providing the ability to handle meaningful objects rather than normalized single records. A conception will be greatly reduces the semantic gap between the reality world and the database representation, while at the same time object oriented database are also offering a more precise semantic definition of our reality world.

4.4 Characteristic and advantages of object relational database

Nowadays object-relational database is the third type of the database. It is also are a system that "attempt to extend relational database system with the functionality necessary to support a broader class of application and, in other ways, provide a bridge between the relational and object-oriented paradigms." It is s system that is allowing developers to unite the database with their own custom data types and custom methods. The main purpose of object relational database technology is to allow the developers to raise the level of the abstraction at which they view the problem domain.

Object-Relational database was created to handle the new types of data such as video, audio, image files that are relational databases that are not equipped for handle. Furthermore, its development has the result of increased usage of object-oriented programming languages, and a large mismatch between these and the DMBS software. Object relational database management system is a database management system with the similar to a relational database, except that it has an object-oriented database model. These systems are supporting the object, classes and inheritance in database schemas and query language. It is also a system that provides a relation bond between relational and object-oriented databases. Object-relational database management system, data is manipulating by using queries in a query language. These systems are the bridge of the gap between conceptual data modeling techniques such as entity relationship diagrams and object relational mapping are using classes and inheritance. Object relational database management system also support data model extensions with custom data types and methods. This allows developers to rise the abstraction levels at which problem domain are viewed.

The advantage of the object-relational database is that are allowing the organizations to continue using their existing system, and without having to make major changes in the system. Allowing users and programmers to start using object-oriented systems in parallel is the second advantages of object-relational database. Advanced into the Internet and Web Age also is another advantages for object-relational database. The data which are stored is widely being accessed through a web browser. Queries that are being generated through Web-accessible forms and answers are being formatted using a mark-up language. Furthermore, there are many vendors and distributors are adding features to their databases at making a better equipped for Internet usage.

5.0 Conclusion & Recommendation

Databases are just like a table to manipulate, add, retrieve, delete and manage your data. It is mostly will be used at office, school, hospital and many more. Which is also means that the place that are many people need to check in or check out will probably have the database. In the database, there are row and column to record down a person's information for everything, so that it will be very convenient for those users and also help a lot of people for the prove.

As an example in a college, there are principle, coordinator, lecturer, cleaning agent and student. So in a college there are many identity people with different occupation to do. So that college is need a database to control and manipulate the data and information of each person in the college. By differentiate all people in different occupation by using a code like index number or other identical number for each different people. So the person will have his own identity and their aim for in this college. The code can be the primary key for the detail of a person, but the code in the foreign key are the detail where they use the place, like an example, lecturer's department are in the office, student may using the auditorium, laboratory or normal classes too. This is the information to represent their places to use.

In addition, databases are not only using only for person, it may be able to be an object or an item like, in the supermarket, database can be use at employee, staff and customer. Except this, databases also can use at marking and tagging the stock every period of time. It also can use in monthly earn, top selling, best promote and many other categories. So the stocking department will be convenient with the database, they can count the stock easily. Cashier also will be easier to check the monthly balances, and the mistake will be greatly reduces as maximum as possible.

6.0 Appendix