GGITS

DBMS CONCEPTS
Database : A database is a collection of stored operational data used by various applications and/or users by some particular enterprise or by a set of outside authorized applications and authorized users. DataBase Management System : A DataBase Management System (DBMS) is a software system that manages execution of users applications to access and modify database data so that the data security, data integrity, and data reliability is guaranteed for each application and each application is written with an assumption that it is the only application active in the database. What Is Data ? •Different view points: –A sequence of characters stored in computer memory or storage –Interpreted sequence of characters stored in computer memory or storage –Interpreted set of objects – Database supports a concurrent access to the data File Systems : •File is uninterpreted, unstructured collection of information •File operations: delete, catalog, create, rename, open, close, read, write, find, … •Access methods: Algorithms to implement operations along with internal file organization •Examples: File of Customers, File of Students; Access method: implementation of a set of operations on a file of students or customers. File Management System Problems : •Data redundancy •Data Access: New request-new program •Data is not isolated from the access implementation •Concurrent program execution on the same file •Difficulties with security enforcement •Integrity issues . Database Applications : •Airline Reservation Systems – Data items are: single passenger reservations; Information about flights and airports; Information about ticket prices and tickets restrictions. •Banking Systems – Data items are accounts, customers, loans, mortgages, balances, etc. Failures are not tolerable. Concurrent access must be provided •Corporate Records – Data items are: sales, accounts, bill of materials records, employee and their dependents ADVANTAGES OF A DBMS: Data independence: Application programs should be as independent as possible from details of data representation and storage. The DBMS can provide an abstract view of the data to insulate application code from such details. cient data access: A DBMS utilizes a variety of sophisticated techniques to store and retrieve data efciently. This feature is especially important if the data is stored on external storage devices.
GyanGanga Institute Of Technology & Sciences Page 1

Also. •Conceptual – corresponds to the second view of data: What we want the data to express and what relationships between data we must express. In a relational DBMS. Data Levels and their Roles : •Physical – corresponds to the first view of data: How data is stored. Data administration: When several users share the data. before inserting salary information for an employee. Reduced application development time: Clearly. how data is modified. can be responsible for organizing the data representation to minimize redundancy and for ne-tuning the storage of the data to make retrieval efcient. Such applications are also likely to be more robust than applications developed from scratch because many important tasks are handled by the DBMS instead of being implemented by the application. Experienced professionals who understand the nature of the data being managed. This. Further. what “ story” data tells. is data ordered. in conjunction with the high-level interface to the data. The conceptual schema (sometimes called the logical schema) describes the stored data in terms of the data model of the DBMS.GGITS Data integrity and security: If data is always accessed through the DBMS. the DBMS supports many important functions that are common to many applications accessing data stored in the DBMS. centralizing the administration of data can oer signi cant improvements. EBCDIC. the DBMS can check that the department budget is not exceeded. such as students GyanGanga Institute Of Technology & Sciences Page 2 . In our sample university database.…) . the physical schema summarizes how the relations described in the conceptual schema are actually stored on secondary storage devices such as disks and tapes. the DBMS can enforce access controls that govern what data is visible to dierent classes of users. concarence recovery: A DBMS schedules concurrent accesses to the data in such a manner that users can think of the data as being accessed by only one user at a time. the DBMS can enforce integrity constraints on the data. how is it accessed. how data items are actually represented (ASCI. We must decide what le organizations to use to store the relations. the DBMS protects users from the eects of system failures. facilitates quick development of applications.The physical schema speci es additional storage details. are all data necessary for the “story’ are discussed. and create auxiliary data structures called indexes to speed up data retrieval operations. and how dierent groups of users use it. Essentially. For example. the conceptual schema describes all relations that are stored in the database. how data is allocated to computer memory and/or peripheral devices. these relations contain information about entities.

sal: real) Courses(cid: string. age: integer. All student entities can be described using records in a Students relation. address: string. and is usually represented as a tree of relational operators. rno: integer. and the choice of elds for each relation. This layer includes a variety of software for supporting the concept of a le.GGITS and faculty. login: string. credits: integer) Rooms(rno: integer. time: string) The choice of relations. allow data access to be customized (and authorized) at the level of individual users or groups of users. as we saw earlier. For example. cid: string) Meets In(cid: string. which uses information about how the data is stored to produce an effcient execution plan for evaluating the query. name: string. •View – corresponds to the third view of data:What part of the data is seen by a specific application . as well as course enrollments. and the process of arriving at a good conceptual schema is called conceptual database design. we might ant to allow students to nd out the names of faculty members teaching courses. and about relationships. leading to the following conceptual schema: Students(sid: string.External schemas. In fact. cname: string. fname: string. is a GyanGanga Institute Of Technology & Sciences Page 3 . which. in a DBMS. An execution plan is a blueprint for evaluating a query. the parsed query is presented to a query optimizer. fname: string. grade: string) Teaches( d: string. which usually are also in terms of the data model of the DBMS. capacity: integer) Enrolled(sid: string. cid: string. enrollment: integer) STRUCTURE OF A DBMS: When a user issues a query. is not always obvious.The external schema design is guided by end user requirements. gpa: real) Faculty( d: string. This can be done by de ning the following view: Courseinfo(cid: string. such as students' enrollment in courses. each collection of entities and each collection of relationships can be described as a relation. The code that implements relational operators sits on top of the le and access methods layer.

where the data is stored.The les and access methods layer code sits on top of the buer manager.. deallocate. The DBMS supports concurrency and crash recovery by carefully scheduling user requests and maintaining a log of all changes to the database.There are two ways to do this: • By providing an application program interface (set of procedures) that can be used to send DML and DDL statements to the database.. and the recovery manager.. Entity-Relationship data model (mainly for database design) ..GGITS collection of pages or a collection of records.... The disk space manager.. In addition to keeping track of the pages in a le. which is responsible for maintaining a log. called the disk space manager. The lowest layer of the DBMS software deals with management of space on disk. Data constraints. Other older models:   Network model . which ensures that transactions request and release locks according to a suitable locking protocol and schedules the execution transactions. as well as indexes. or le of unordered pages. this layer organizes the information within a page. the lock manager. Database Access from Application Programs: To access the database.....The Open Database GyanGanga Institute Of Technology & Sciences Page 4 . and write pages through (routines provided by) this layer.     Data. Relational model.. Hierarchical model. DBMS components associated with concurrency control and recovery include the transaction manager. Data Models: A collection of tools for describing. read. This layer typically supports a heap le. Higher layers allocate. buer manager.  Semistructured data model (XML). which brings pages in from disk to main memory as needed in response to read requests.. which keeps track of requests for locks and grants locks on database objects when they become available. and le and access method layers must interact with these components. Data relationships. and retrieve the results. Object-based data models (Object-oriented and Object-relational). and restoring the system to a consistent state after a crash. Data semantics. DML statements need to be executed from the host language.

a special character prefaces DML calls.       Database Administrator:A person who has such central control over the system is called a database administrator (DBA) Schema definition. Entity set:An entity set is a set of entities of the same type that share the same properties. Sophisticated users interact with the system without writing programs. called the DML precompiler. For example. Schema and physical-organization modification. Routine maintenance. Granting of authorization for data access. Usually. converts the DML statements to normal procedure calls in the host language. data semantics. The DBA carries out changes to the schema and physical organization to reflect the changing needs of the organization. can be defined as the entity set customer. and a preprocessor. Data Model: A data model is a collection of conceptual tools for describing data. • By extending the host language syntax to embed DML calls within the host language program. Attributes are descriptive properties possessed by each member of an entity set. They submit each such query to a query processor. Entity:An entity is a ―thing‖ or ―object‖ in the real world that is distinguishable from all other objects. An entity is represented by a set of attributes. or to alter the physical organization to improve performance. the entity set loan might represent the set of all loans awarded by a particular bank. Storage structure and access-method definition. Specialized users are sophisticated users who write specialized database applications that do not fit into the traditional data-processing framework. Analysts who submit queries to explore data in the database fall in this category. The designation of an attribute for an entity set expresses that the GyanGanga Institute Of Technology & Sciences Page 5 . and consistency constraints.they form their requests in a database query language.GGITS Connectivity (ODBC) standard defined by Microsoft for use with the C language is a commonly used application program interfacestandard. The DBA creates the original database schema by executing a set of data definition statements in the DDL. Similarly. each person in an enterprise is an entity. Database Users and Administrators:     Naive users are unsophisticated users who interact with the system by invoking one of the application programs that have been written previously. orattributes. Application programmers are computer professionals who write application programs. whose function is to break down DML statements into instructions that the storage manager understands. The set of all persons who are customers at a given bank. Instead. data relationships. The Java Database Connectivity (JDBC) standard provides correspondingfeatures to the Java language. for example.

An entity in A is associated with at most one entity in B. This type of attribute is said to be multivalued. Similarly. Keys also help uniquely identify relationships. middle-initial. allow us to identify uniquely an entity in the entity set. and last-name. the loan-number attribute for a specific loan entity refers to only one loan number. superkey:A superkey is a set of one or more attributes that. although they can contribute to the description of relationship sets that involve more than two entity sets. however. For instance. express the number of entities to which another entity can be associated via a relationship set. GyanGanga Institute Of Technology & Sciences Page 6 . Mapping Cardinalities:Mapping cardinalities. and different employees may have different numbers of phones. An entity in B. or several phone numbers. the combination of customer-name and customer-id is a superkey for the entity set customer. can be divided into subparts is called as "composite attributes". For example. Many to one. Many to many. however. and an entity in B is associated with at most one entity in A. that is. they are not divided into subparts is called as "simple attributes". One to many. An entity in B. customer-id is a superkey. can be associated with any number (zero or more) of entities in A. A relationship set is a set of relationships of the same type. Derived attribute:The value for this type of attribute can be derived from the values of other related attributes or entities.     One to one. or cardinality ratios.For example. Single-valued and multivalued attributes:For instance. taken collectively. and thus distinguish relationships from each other. each entity may have its own value for each attribute. Mapping cardinalities are most useful in describing binary relationship sets. one.We can derive the value for this attribute by counting the number of loan entities associated with that customer. Simple and composite attributes:the attributes havebeen simple. on the other hand. An entity in A is associated with any number (zero or more) of entities in B.GGITS database stores similar information concerning each entity in the entity set. An entity in A is associated with at most one entity in B. which represents how many loans a customer has from the bank. because several people might have the same name. There may be instances where an attribute has a set of values for a specific entity. however. the customer-id attribute of the entity set customer is sufficient to distinguish one customer entity from another. An employee may have zero. Such attributes are said to be single valued. Thus. an attribute name could be structured as a composite attribute consisting of first-name. An entity in A is associated with any number (zero or more) of entities in B. let us say that the customer entity set has an attribute loans-held. Keys: A key allows us to identify a set of attributes that suffice to distinguish entities from each other. Relationship Sets:A relationship is an association among several entities. and an entity in B is associated with any number (zero or more) of entities in A. can be associated with at most one entity in A. The customer-name attribute of customer is not a superkey. Consider an employee entity set with the attribute phone-number.

GGITS candidate key:minimal superkeys are called candidate keys. then so is any superset of K. that is.Suppose that a combination of customer-name and customer-street is sufficient to distinguish among members of the customer entity set.primary key to denote a candidate key that is chosen by the database designer as the principal means of identifying entities within an entity set. candidate. and the participation of the weak entity set in the relationship is total. Such an entity set is termed a weak entity set. We are often interested in superkeys for which no proper subset is a superkey. it must be associated with another entityset. Every weak entity must be associated with an identifying entity. Then. Weak Entity Sets:An entity set may not have sufficient attributes to form a primary key. The discriminator of a weak entity set is a set of attributes that allows this distinction to be made. called the identifying or owner entity set. The designation of a key represents a constraint in the real-world enterprise being modeled.If K is a superkey. the identifying entity set for payment is loan. since the attribute customerid alone is a candidate key. For a weak entity set to be meaningful. In our example. and super) is a property of the entity set. and a relationship loan-payment that associates payment entities with their corresponding loan entities is the identifying relationship. both {customer-id} and {customer-name. Although a weak entity set does not have a primary key. rather than of the individual entities. GyanGanga Institute Of Technology & Sciences Page 7 . The relationship associating the weak entity set with the identifying entity set is called the identifying relationship. customer-street} are candidate keys. The identifying entity set is said to own the weak entity set that it identifies. A key (primary. we nevertheless need a means of distinguishing among all those entities in the weak entity set that depend on one particular strong entity. the weak entity set is said to be existence dependent on the identifying entity set. primary key:which denotes the unique identity is called as primary key. The identifying relationship is many to one from the weak entity set to the identifying entity set. their combination does not form a candidate key. Although the attributes customerid and customer-name together can distinguish customer entities.It is possible that several distinct sets of attributes could serve as a candidate key. Any two individual entities in the set are prohibited from having the same value on the key attributes at the same time. An entity set that has a primary key is termed a strong entity set.

New levels of entity representation will be distinguished (specialization) or synthesized (generalization) as the design schema comes to express fully the database application and the user requirements of the database. customer entities may be described further by the attribute customer-id. a subset of entities within an entity set may have attributes that are not shared by all the entities in the entity set. The database designer may have first identified a customer entity set with the attributes name. a doubly outlined box indicates a weak entity set. For instance.and lower-level entity sets also may be designated by the terms super class and subclass. and salary. A personmay be further classified as one of the following: • customer • employee Each of these person types is described by a set of attributes that includes all the attributes of entity set person plus possibly additional attributes. In our example. with attributes name. Finally. The specialization of person allows us to distinguish among persons according to whether they are employees or customers.GGITS In E-R diagrams. street. ratherthan a solid. they are described by the same attributes and participate in the same relationship sets). Differences in the two approaches may be characterized by their starting point and overall goal. line. Consider an entity set person. For example. and a doubly outlined diamond indicates the corresponding identifying relationship. and customer-id. meaning that every payment must be related via loan-payment to some loan. generalization is a simple inversion of specialization. Generalization proceeds from the recognition that a number of entity sets share some common features (namely. person is the higher-level entity set and customer and employee are lower-level entity sets. street. In terms of the E-R diagram itself. city. We will apply both processes. in the course of designing the E-R schema for an enterprise. The discriminator of a weak entity set also is underlined. The process of designating subgroupings within an entity set is called specialization. which is a containment relationship that exists between a higher-level entity set and one or more lower-level entity sets. Generalization:The design process may also proceed in a bottom-up manner. GyanGanga Institute Of Technology & Sciences Page 8 . This commonality can be expressed by generalization. in combination. employeeid. The E-R model provides a means for representing these distinctive entity groupings. and city. we do not distinguish between specialization and generalization. whereas employee entities may be described further by the attributes employee-id and salary. There are similarities between the customer entity set and the employee entity set in the sense that they have several attributes in common. in which multiple entity sets are synthesized into a higher-level entity set on the basis of common features. but with a dashed. The figure also illustrates the use of double lines to indicate total participation—the of the (weak) entity set payment in the relationship loan-payment is total. the arrow from loan-payment to loan indicates that each payment is for a single loan. The person entity set is the super class of the customer and employee subclasses. street. respectively. city.For all practical purposes. and an employee entity set with the attributes name.in fig the weak entity set payment depends on the strong entity set loan via the relationship set loan-payment. Specialization:An entity set may include subgroupings of entities that are distinct in some wayfrom other entities in the set. Higher.

GGITS Aggregation: Aggregation is an abstraction in which relationship sets (along with their associated entity sets) are treated as higher-level entity sets. Symbols used in the E-R notation: GyanGanga Institute Of Technology & Sciences Page 9 . and can participate in relationships.

GGITS ER Model For a college DB: Assumptions :           A college contains many departments Each department can offer any number of courses Many instructors can work in a department An instructor can work only in one department For each department there is a Head An instructor can be head of only one department Each instructor can take any number of courses A course can be taken by only one instructor A student can enroll for any number of courses Each course can have any number of students Steps in ER Modeling: GyanGanga Institute Of Technology & Sciences Page 10 .

Course# (CourseId) is the key attribute for ―Course‖ Entity. Each department there is a ―Head of department‖ and one instructor is ―Head of department ―. hence the cardinality between course and instructor is many to one. hence the cardinality between department and course is One to Many. as it identifies the Department uniquely.duration. hence the cardinality between department and instructor is one to Many. hence the cardinality between course and student is Many to Many. telephone#  For student entity. course name.prerequisite  For instructor entity. student name. the relevant attribute is location  For course entity. One course is taught by only one instructor. Step 3: Identify the key attributes      Deptname is the key attribute for the Entity ―Department‖. date of birth GyanGanga Institute Of Technology & Sciences Page 11 . Student# (Student Number) is the key attribute for ―Student‖ Entity. Step 4: Identify other relevant attributes For the department entity. One department has multiple instructors and one instructor belongs to one and only one department .hence the cardinality is one to one . but the instructor teaches many courses. The department offers many courses and each course belongs to only one department.GGITS      Identify the Entities Find relationships Identify the key attributes for every Entity Identify other relevant attributes Draw complete E-R diagram with all attributes including Primary Key Step 1: Identify the Entities:     DEPARTMENT STUDENT COURSE INSTRUCTOR Step 2: Find the relationships:      One course is enrolled by multiple students and one student enrolls for multiple courses. Instructor Name is the key attribute for ―Instructor‖ Entity. room#.

hence the GyanGanga Institute Of Technology & Sciences Page 12 . • One Branch offers many loans and each loan is associated with one branch.GGITS ER model for Banking Business : Assumptions :     There are multiple banks and each bank has many branches. hence the cardinality between Bank and Branch is One to Many. Each branch has multiple customers Customers have various types of accounts Some Customers also had taken different types of loans from these bank branches One customer can have multiple accounts and Loans Step 1: Identify the Entities • BANK • BRANCH • LOAN • ACCOUNT • CUSTOMER Step 2: Find the relationships • One Bank has many branches and each branch belongs to only one bank.

the relevant attribute other than ―Account No‖ would be ―Account Type‖. the relevant attributes other than ―Customer#‖ would be ―Name‖. • Loan# (Loan Number) is the key attribute for ―Loan‖ Entity. • For the ―Account‖ Entity. hence the cardinality between Customer and Account is Many to Many Step 3: Identify the key attributes • BankCode (Bank Code) is the key attribute for the Entity ―Bank‖. the relevant attribute other than ―Loan#‖ would be ―Loan Type‖. • For the ―Customer‖ Entity. • One Customer can hold multiple accounts. the relevant attributes other than ―Branch#‖ would be ―Name‖ and ―Address‖. • Customer# (Customer Number) is the key attribute for ―Customer‖ Entity. hence the cardinality between Branch and Account is One to Many • One Loan can be availed by multiple customers. Step 4: Identify other relevant attributes • For the ―Bank‖ Entity. • For the ―Loan‖ Entity. E-R diagram with all attributes including Primary Key: GyanGanga Institute Of Technology & Sciences Page 13 .GGITS cardinality between Branch and Loan is One to Many. • Branch# (Branch Number) is the key attribute for ―Branch‖ Entity. • Account No (Account Number) is the key attribute for ―Account‖ Entity. and each Account can be held by multiple Customers. • One Branch maintains multiple accounts and each account is associated to one and only one Branch. as it identifies the bank uniquely. the relevant attributes other than ―BankCode‖ would be ―Name‖ and ―Address‖. ―Telephone#‖ and ―Address‖. • For the ―Branch‖ Entity. hence the cardinality between Loan and Customer is Many to Many. and each Customer can avail multiple loans.