DSC-301 Computer Science Paper V PDF
Document Details
Uploaded by InspirationalBlueTourmaline
null
Tags
Summary
This document introduces Relational Database Management System (RDBMS). It explains concepts like Data, Information, and Database, along with Database Management Systems (DBMS) and Relational Database Management Systems (RDBMS). It also covers the Concepts of Data Models and a simple example of an Entity-Relationship diagram.
Full Transcript
DSC-301: Computer Science Paper-V Relational Database Management System Unit-I: Introduction to RDBMS Data: Data is defined as collection of raw facts about a place, person, thing or object involving in the transactions of an organization. Data c...
DSC-301: Computer Science Paper-V Relational Database Management System Unit-I: Introduction to RDBMS Data: Data is defined as collection of raw facts about a place, person, thing or object involving in the transactions of an organization. Data can be represented in various forms like text, numbers, images, audio, video, graphs, document files, etc. Data constitutes the building blocks of information. Data is one of the important assets of the modern business. Data becomes relevant based on the context. Information: Information can be defined as processed data that increases the knowledge of end user. Information is used to reveal the meaning of data. Good, accurate and timely information is used in decision making. The quality of data influences the quality of information. Information can be presented in the tabular form, bar graph or an image Database: Database can be defined as organized collection of logically related data. Database can be of any size and complexity. Data are structured so as to be easily stored, manipulated, and retrieved by users. Example: Sales person can store customers contacts on his laptop that consist of few mega bytes of data or A big company can store the data of all activities in the organization which helps in decision making.. DBMS: Database management system can be defined as reorganized collection of logically related data and set of programs used for creating, storing, updating and retrieval of data from the database. DBMS acts as a mediator between end-user and the database. Database management system (DBMS): can be defined as collection of programs that manages database structure and controls access to data. DBMS enables data to be shared. DBMS integrates many users’ views of the data. RDBMS: RDBMS stands for Relational Database Management System. All modern database management systems like SQL, MS SQL Server, IBM DB2, ORACLE, My-SQL, and Microsoft Access are based on RDBMS. It is called Relational Database Management System (RDBMS) because it is based on the relational model introduced by E.F. Codd. Data is represented in terms of tuples (rows) in RDBMS. A relational database is the most commonly used database. It contains several tables, and each table has its primary key. Due to a collection of an organized set of tables, data can be accessed easily in RDBMS. Concepts of Data Models A Database model defines the logical design and structure of a database and defines how data will be stored, accessed and updated in a database management system. 1. Object based data models E-R model Object Oriented data model Entity-Relationship (ER) model Entity-Relationship (ER) Model is based on the notion of real-world entities and relationships among them. While formulating real-world scenario into the database model, the ER Model creates entity set, relationship set, general attributes and constraints. ER Model is best used for the conceptual design of a database. ER Model is based on − Entities and their attributes. Relationships among entities. These concepts are explained below. A simple ER Diagram: In the following diagram we have two entities Student and College and their relationship. The relationship between Student and College is many to one as a college can have many students however a student cannot study in multiple colleges at the same time. Student entity has attributes such as Stu_Id, Stu_Name & Stu_Addr and College entity has attributes such as Col_ID & Col_Name. Here are the geometric shapes and their meaning in an E-R Diagram Rectangle: Represents Entity sets. Ellipses: Attributes Diamonds: Relationship Set Lines: They link attributes to Entity Sets and Entity sets to Relationship Set Double Ellipses: Multivalve Attributes Dashed Ellipses: Derived Attributes Double Rectangles: Weak Entity Sets Double Lines: Total participation of an entity in a relationship set Components of ER diagram As shown in the above diagram, an ER diagram has three main components: 1. Entity 2. Attribute 3. Relationship 1. Entity An entity is an object or component of data. An entity is represented as rectangle in an ER diagram. For example: In the following ER diagram we have two entities Student and College and these two entities have many to one relationship as many students study in a single college. We will read more about relationships later, for now focus on entities. Weak Entity: An entity that cannot be uniquely identified by its own attributes and relies on the relationship with other entity is called weak entity. The weak entity is represented by a double rectangle. For example – a bank account cannot be uniquely identified without knowing the bank to which the account belongs, so bank account is a weak entity. 2. Attribute An attribute describes the property of an entity. An attribute is represented as Oval in an ER diagram. There are four types of attributes: 1. Key attribute 2. Composite attribute 3. Multivalve attributes 4. Derived attribute 1. Key attribute: A key attribute can uniquely identify an entity from an entity set. For example, student roll number can uniquely identify a student from a set of students. Key attribute is represented by oval same as other attributes however the text of key attribute is underlined. 2. Composite attribute: An attribute that is a combination of other attributes is known as composite attribute. For example, In student entity, the student address is a composite attribute as an address is composed of other attributes such as pin code, state, country. 3. Multivalve attributes: An attribute that can hold multiple values is known as multivalued attribute. It is represented with double ovals in an ER Diagram. For example – A person can have more than one phone numbers so the phone number attribute is multivalued. 4. Derived attribute: A derived attribute is one whose value is dynamic and derived from another attribute. It is represented by dashed oval in an ER Diagram. For example – Person age is a derived attribute as it changes over time and can be derived from another attribute (Date of birth). E-R diagram with multivalve and derived attributes: 3. Relationship (Mapping Cardinalities) A relationship is represented by diamond shape in ER diagram, it shows the relationship among entities. There are four types of relationships: 1. One to One 2. One to Many 3. Many to One 4. Many to Many 1. One to One Relationship: When a single instance of an entity is associated with a single instance of another entity then it is called one to one relationship. For example, a person has only one passport and a passport is given to one person. 2. One to Many Relationship: When a single instance of an entity is associated with more than one instances of another entity then it is called one to many relationship. For example – a customer can place many orders but a order cannot be placed by many customers. 3. Many to One Relationship: When more than one instances of an entity is associated with a single instance of another entity then it is called many to one relationship. For example – many students can study in a single college but a student cannot study in many colleges at the same time. 4. Many to Many Relationship: When more than one instances of an entity is associated with more than one instances of another entity then it is called many to many relationship. For example, a can be assigned to many projects and a project can be assigned to many students. Object Oriented data model The Object Oriented data model (OODM) is a better representation of real-world challenges. Both the data and the relationship are contained into a single structure that’s known as an object in this model. We can now store audios, pictures, videos, and other types of data in databases, which was previously impossible with the relational approach Here is an example of this model: Multiple objects are connected in this model using connections. The following example can help you understand this. The Employee and Department are the two objects in the example above. Each object’s data and the relationships are there in a single unit. Here, the attributes of the employee, such as Name and Job_title, as well as the methods that will be performed by that object, are all kept in a single object. The two objects are linked by a common attribute, i.e., Department_id, as well as communication between them will be accomplished by this common id. Advantages of Object Oriented Data Model: Codes can be reused due to inheritance. Easily understandable. Cost of maintenance can reduced due to reusability of attributes and functions because of inheritance. Disadvantages of Object Oriented Data Model: It is not properly developed so not accepted by users easily. 2. Record-Based Data Model: When the database is organized in some fixed format of records of several than the model is known as Record-Based Data Model. It has a fixed number of fields or attributes in each record type and each field is usually of a fixed length. Further, it is classified into three types- i. Hierarchical Data Model : This database model organizes data into a tree-like-structure, with a single root, to which all the other data is linked. The hierarchy starts from the Root data, and expands like a tree, adding child nodes to the parent nodes. In this model, a child node will only have a single parent node. This model efficiently describes many real-world relationships like index of a book, recipes etc. In hierarchical model, data is organized into tree-like structure with one one-to-many relationship between two different types of data, for example, one department can have many courses, many professors and of-course many students. Advantages – Simplicity, Data Integrity, Data security, Efficiency, Easy availability of expertise. Disadvantages – Complexity, Inflexibility, Lack of Data Independence, Lack of querying facility, Lack Of standards. ii. Network Data Model: This is an extension of the Hierarchical model. In this model data is organised more like a graph, and are allowed to have more than one parent node. In this database model data is more related as more relationships are established in this database model. Also, as the data is more related, hence accessing the data is also easier and fast. This database model was used to map many-to-many data relationships. This was the most widely used database model, before Relational Model was introduced. For Example- Social Media sites like Facebook, Instagram etc. Advantages – Simplicity, Data Integrity, Data Independence, Database standards. Disadvantages – System Complexity, Lack of structural Independence. iii. Relational Data Model: Relational Data Model uses tables to represent the data and the relationship among these data. Each table has multiple columns and each column is identified by a unique name. It is a low-level model. Advantages – Structural Independence, Simplicity, Ease of designing, Implementation, Ad-Hoc query capability. Disadvantages – Hardware Overheads, Ease of design can result in bad design. 3. Physical Data Model: Ultimately, all data in a database is stored physically on a secondary storage device such as discs and tapes. This is stored in the form of files, records and certain other data structures. It has all the information of the format in which the files are present and the structure of the databases, presence of external data structures and their relation to each other. A physical data model is a database-specific model that represents relational data objects (for example, tables, columns, primary and foreign keys) and their relationships.