You are on page 1of 30
[Pr C9 ~The database approach has many important characteristics due to which database has become an integral part of the software industry. ‘Tho various charactoriatics of tho DBMS aro.as mentioned below Fig. 121: Characteristics of DBMS Data integrity = __Integrty constraints provide a way of ensuring that changes made in the database by Wiese Scanned by CamScanner DBMS (MU- Sem = ir IntoduetonDatabaee Conn, ‘authorized sere that donot result in the loss of data consistency and correctness, = Database integrity 4 concerned with the correctness and completeness of data in y, database, = This objective can never be guaranced, one cannot ease that every entry made, database is accurate, ~ Some examples of ncoret data ae as below : 1. Student taking admission to branch which isnot available in eae 2. Employee assigned with non existing department. 3. Sometime inconsistency introduced due o system failures. 2. Data security ~ A DBMS system always has a seperate system for security which is responsible fa; protecting database against accidental or intentional loss, destruction or misuse. - Dazain database shouldbe given to only authorized users. = Only authorized users should be allowed to modify data. ‘Authorized uses are able to access data any time he wants, ‘3. Data independence Data Independence can be defined as the capacity to change data kept at one place ‘without changing data kept at other locations 4, Transaction control - Rollback ‘The changes made inthe database can be reverted back with help ofrolibaek command. @ scanned with OKEN Scanner —___Integrity constraints provide a way of ensuring that changes made in the database by ‘Scanned by CamScanner DBMS (MU- Sem 5 14 Inoducton Deabese Coe, ‘authorized users that do not result inthe loss of data consistency and comectnes, = Database integrity 15 concemed with the correcness and completeness of data ing, database, = This objective can never be guaranteed, one cannot ensre that every entry mais database is accurate = Some examples of incorrect data areas below : 1, Student taking admission to branch which isnot aval 2. Employee assigned with non existing department. 3. Sometime inconsistency introduced due to system failures. 2 Data security = ADBMS system always has a separate system for security which is responsible fr protecting database against accidental or intentional loss, destruction or misuse. Data in database shouldbe given to only authorized users, f = Only authorized users should be allowed to modify data. = Authorized users are able to access data any time te wants, 3. Data independence : Daa Independence can be defined as the capacity to change data kept at one pst ‘without changing data kept at other locations. 4, Transaction control - Rollback = Thechanges made in the database can be reverted back with help of olftack command. ~The changes canbe saved successfully with the help of commit data command. 5. Concurrency control = The datain database can be accessed by multiple users at same point of time. = Such operations are allowed by sharing same data between multiple users. 6, Data recovery - Backup and Restore Database recovery isthe process of restoring the database to original (core) stat fet database failure. : ‘Scanned by CamScanner DBMS (MU - Som -Coms) 1 Intoducton Database Ct “The main element of database recovery is the most recent database backup, If you maintain database backup efficiently, then database recovery is very siight forward process. 4.3 File System v/s Databaso System Tr ines te advantages of Baabos ton ove Flee elon. I'm. Fyeiain advantages of DE @ scanned with OKEN Scanner eee am vis Database Sys [{@. Discuss the advantages of Database sysiem over Files eyster Qi Explain advantages of DEMS over fe system, .Q. List four signticant itforonces between fle processing (Eman) (10 marks) __ system ad etabase management system, Redundancy can be reduced ‘As we are using relational approach for data organi ‘one location Repet Inconsistency ean be avoided tion, data is not stored in more than n of information can be avoided which in tun saves storage space, ‘The database assures that al he users access actual or true data present in the database, 3. Data can be shared — Mutkiple users can login at ime into the database to acces information, — They ean manipulate the database ins contrlled environment Example Jn yahoo portal, many users are accessing dain database in a controlled manner. 4. Centralized control of data ‘With a centralized control of data, sh database system may be designed for an overall pimal performance for entire organization. 5. Standards canbe enforced Standards (rules and regulations for coding and desi KS aa = Fig. 3.2.2: Employee entity (@) Weak entity type = Thesetypes of entities are dependent on strong entity for primary key. = For some weak entities we assign virwal primary key. Such virtual primary key of weak entity is called as ‘discriminator’. ~ Weakenty type is represented by double rectangle [[—] Example: = Incase of*Dependent” entity depend on employee entity for primary key. @ scanned with OKEN Scanner ~ Incase of “Dependent” entity depend on employee entity for primary key. on Key attibutes. Explain various type of kev in ER Digger, Ineducton = Each ent has ts own properties wtich describes ta ently sich properties are komm as tbe. ~The attribute value that describes each entity becomes major part of data stored in database. entity may be deseribed by Scanned by CamScanner Wows guy -soms-c: Entity Relatonthio Daa Woe, Attribute {(Simple/Single vvalued/Stored) — Aparticular entity will have some value foreach ofits attributes. Example: = Foranemployee of with Employec_id 30, the name attribute value is “Jayendra’ — Thevvarious types of atibute are used in ER diagrams, a | (wi cone AURAteS (WMsivaued arbaes (eDevived Anes (ot anes Fig. 33.1 : Types of attribute are used in ER diagrams (@ Composite Attributes = Theattributes which can be divided in multiple subparts. Fesseype sn NT ome Conposicatribue | E> SD — + The divisible attributes are composite attibutes. Example: ‘The Name attribute of Student table can be divided into FirstName and LastName. @ scanned with OKEN Scanner Scanned by CamScanner 34 Entty Relatonship Data to, (Simplesinge | <> valued/iored) = A particular entity will have some value for each ofits attributes. Example: = Foran employee of with Employee_id 30, the name attribute value is “Sayendra’ ~The various types of attribute are used in ER diagrams, [tanneries (Key abuts Fig.3.3.1 : Types of attribute are used in ER diagrams (@) Composite Attributes — Theattributes which can be divided in multiple subparts, Saye Noho Compsicatibus | <> SD ~ + Thedivisibleattbutes are composite attributes. * Example: ‘The Name atribute of Student table canbe divided into Firt_Name and Last Name. ‘Scanned by CamScanner W_ aus (w-Sem5--Coms) 35 Enty Relatonthis Data Mode! (@) Muttivalued Attributes ‘The attribute having more then one value for a same entity is called as multi-valued attribute. ae Notation Multivalued Attribute —<_> @ scanned with OKEN Scanner Example: ‘The Name atribute of Student table can be: Scanned by CamScanner W_pous (mu Sems- Comp) 35 Entity Relationship Data Mode! (@) Multivalued Attributes ‘The attribute having more then one value for a same entity is called as multi-valued attribute. ype: Notation, Multivalued Attribute —<_> ‘A Single student can have multiple mobile numbers. a> Example: Fig. 33.2 Mult valued attributes (© Derived Attributes Example: Employee tenure can be calculated from stored stribute ‘Date_of joining’ of employee by subtracting it from today's date Fig. 3.34 : Derived attributes ‘Scanned by CamScanner Relatonship Data Mace @ scanned with OKEN Scanner ee Eel] Fig. 3.3.4: Derived attributes Scanned by CamScanner M_pons wy Som $= comp) ity Relatonshlp Data Moca @ Null Attribute = This attribute can take NULL value when entity does not have value for it. = This is a special attribute the value of which is unknown, unassigned, not applicable cr missing. Examplo: . = The 'Net_Banking Active Bin’ attribute gives weather particular custémer having ne, banking facility setivated oF not activated. = For bank which does not offer facility of net banking in customer table ‘Net_Banking Active Bin’ attribute is always null till Net banking facility is no ‘ctvated as this rtibute indicates Bank offers net banking facility or does not offers. ~ These attributes can be used in future se or for unknown, unsigned, missing values of attribute. 7 © Key Attributes ‘This isan atribuie of an entity which must have a unique value by which any row can be identified is called as key attribute of entity, Example Emp_Id for employee. = Thecolumn value that uniquely identifies a single record in a table called as key of table. = Anattribute or set of attributes whose values uniquely identify each entity in an entity se iscalled a key for that entity set. | = Disakey of student table. It is possible to have only one student with one 1D (Say only ‘one student ‘Mahesh’ with ID = 1) . Scanned by CamScanner DBMS (MU- Sem 5 - Cony 37 Entity Relatonship Data Mode \ PSiericadt @ scanned with OKEN Scanner niqely Wentfis a single record ina tbl called as key of ble = Thecolumn value that ify each entity in an entity se “An attribute or set of attributes whose values uniquely iden fs called a key for that entity set. _ wisakey of student able. Its posible to have only one cone student ‘Mahesh’ with ID.= 1) ¥ student with one ID (Say on!y ‘Scanned by CamScanner Wy paws ony soms-come 22 Ertty Relatonship Data Model cai Sud PASSPORT_NUM LICENCE_NUMDER SSN DEPARTMENT_NUMBER Fig. 3.3.6 : Key Coneept ‘Typos of Keys ‘The various types of keys in ER Dingrams are as follows, Types of Keys 1. Super Key 2, Composite Key 3. Candidate Key 1, Prinary Key 5, Alemato Koy Secondary Key Fig. 33.7 : Types of keys 1. Super Key = Amatribute or set of attributes that uniquely identifies a single tuple in entity. = There can be more than one super keys in single table Example: In Fig. 336 combination of (Stud 1D, Stud name, Stul Passport Num’ Licence ‘Number, ssn) acts like a super key. 2. Composite Key ‘Any key with more than one altsbutes that uniquely identifies a single tuple in entity. Example: In Fig. 3.36 super key has more than one alribute so, itis a composite Key. ‘Scanned by CamScanner Se _pems wiv-sem5- Comp) 38 Entity Relatonship Data Mocs 3. Candidate Key @ scanned with OKEN Scanner Entily DAMS (MU - Sem 5- Co 3. Candidate Key —_ ‘A super key with minimus number ofatributes is candidate's KeY- No subset of candidate key van be! keys : Liceitee_Numberssn) acts like a tn Fig. 3.3.6 combination of (sud Candidates key. Passport_Num, 4. Primary Key eet Asselected key of ‘that entity. strong entity which uniquely identify tuple in entity is 2 primary Exampl In Fig, 33.6 combination of (Stud_ID) a=18 like a Primary key. 5, Alternate Key ‘ACCandidate key which is not selected 9s primary key. Example: In Fig. 3.3.6 candidate alternate key fe Key (Stud Passport Num, Licence Number, ssn) acts like 6. Secondary Key “An atribute or set of attributes that is used “The secondary key not necessary to be unique to access a single tuple in entity. Example : ‘In Fig. 33.6 attribute (Stud_Passport_Num) can be used for accessing student's data, 89 itis acting like secondary key ytype | ficisen de SuperKey | An attribute or set of atributes that uniquely identifies a single tuple in entity. ‘Composite Key | Any key with more than one attributes that uniquely identifies a single tuple in entity. Candidate Key | A super key with minimum number of attributes is a candidate's key- i Scanned by CamScanner DaMS (MU Sem5 - Com = 22 Relationship Data Model No subset of candidate key van be key. Primary key | A selected key si -y of strong entity which uniquely ident - primary key of that entity. ty which uniquely identify tuple in entity is Altemat i Itemate Key _| A Candidate key which is not selected as primary key 5 j | An attribute or set of aisthutes that acd tn-aoneee @ scanned with OKEN Scanner ee ae ee eee 1 ‘Scanned by CamScanner ae Primary key | A selected key of strong entity which uniquely identify tuple in entity is primary key of that enity. Attemate Key | A Candidate key which is nat selected as primary key ‘No subset of candidate hey van be key. Seeendary Key | An attribute or set of attibutes that used to access a single tuple in entity. 3.4 Relationships = Atelationship is an association among oné or more than one entt ~ Weuse diamond shape to show relationship. = Itistecommended to arrange relationship tobe read it from left to right or up to down. Example: Employee works for Department. Fig. 34.1 + ER Dingram for Works for 2 Relationship Set Colleton of all relationship of same type is relationship set. The many employees are ‘Working for different departments so itis relationship set of Works Forrlationship. 3. Dogree of Relationship ‘The degree of relationship type fs number of patipating entity types in particular relation Scanned by CamScanner DBMS (MU-Sem Cor) 310 Flaionship Data Nagy ‘Types of Relationship based on degree are, © Unary Relationship © Binary Relaonship © Temary Relationship @ scanned with OKEN Scanner ~ The set of subclasses that forms a specialization is defined on the basis of some distinguishing characteristic of entity in super class. Example: Set of subclass (Saving Account, Current Account) are Specialization of super class ‘Scanned by CamScanner Fig.3.62: 2: Spec alization Notation = The subclass defined in a specialization Is attached by lines toa circle which is connectez to superclass, = The subset syribol on each line connecting a subclass to circle indicates the direction of ‘superclass / subclass relationship. ‘Specific attribute ‘Anatribute applied only to entities of particular subclass is called as specific attribute. @ scanned with OKEN Scanner to super clas. = The subset symbol on each line connecting e subclass to circle indicates the direction ot super class / subclass relationship. Specific attribute An attribute applied only to entities of particular subclass is called as specific attribute, 3.6.2 Generalization Starks) ‘(EEE ‘Superclass/subelass relationship. ‘Car and Bike all having several common attribute they can generalize to the super clas vehicle. Notation = A diagrammatic notation to distinguish between generalization and specialization is use! {in some programming methodologies. ‘Scanned by CamScanner 347 Entity Relatonship Data Model ~ Arrow pointing to generalized superclass represents generalization. ~ Arrow pointing to generalized subclass represents specialization, @» cD) poet @axmo0d) LmoD — Bron Fig. 3.6.3 : BIKE entity eres Goad) few} OenerD> CD @ scanned with OKEN Scanner — Duplicate values are not allowed in primary key column, because they cause problems in distinguishing one entity from another (entity may be an employee). The DBMS can prevent user from inserting same data’ values in a column again and 1. Introduction = Avvalue appearing in a one relation (table) fora given set of attributes also appears for another set of attributes in another relation (table). This is called referential integrity. The referential integrity constraint is specified between two tables to maintain the consistency among tuples in the two tables. - Wisinves Scanned by CamScanner Rotational Data Yon - Inthe above example Employee table has Did as foreign key reference to Did column = Department table this is called as referential integrity. — Here we are forcing the database to check the value of Did column from the departs table while inserting any value in Employee table. This helps to maintain dex consistency. 2, Foreign key violations in SQL © Scanned with OKEN Scanner ~ If any row in EMP table is added with ‘Did’ value which is not there in department t2b ‘the insert statement will give foreign key violation error. ~ In above tables we will refer Department as parent table (as itis containing Primary ke) and Employee table as Child table (as itis containing Foreign Key), ~ There are 4 problems causes the foreign key violations, (2) Adding new tuple to Child Table (Add Child) = If we ty to add an employee with Did 70 to employee table (Child Table), it will et foreign key violation error. As Did 70 isnot therein Department table (Parent table) INSERT INTO Employee ‘VALUES (11,"Devie’, 70); Output ORA-02291 ; integrity constraint (Employee.FK_Employee) violated - parent key ™ found — Scanned by CamScanner DBMS (MU Soms a Relational Data Medel ~ This functionality helps to mainiain data consistency in database. (0): Updating tuple from Child Table ~ _ If-we try to update an employee Emp_ld = 2 with Did as 70 to employee table (Child Table), it will return foreign key violation error. As Did 70 is not there in Department table (Parent table). UPDATE Employee SETDid=70 WHERE Emp_} Output ORA-02291 : Integrity constraint (Employee FK_Employee) violated - parent key not found, = This Functionality heips to maintain data consistency in database, (©) Deleting tuple from Parent Table ~ lf we try to delete department of Did = 10 from Department table (Parent table), it will ‘tum foreign key violation error. As thee are few employees working in department with Did =10. DELETE Department WHERE Did=10; Output ‘ORA.02292: integrity constraint (Employee.FK_Employee) violated - child record found ~ This functionality will creates limitation for deletion of parent record if it has some associated child records. (@ Updating tuple from Child Table ~ If we try to update department of Did = 10 with Did = 70, it will retum foreign key violation error. As there are few employees stil working in department with Did =10. UPDATE Department SET Did=70 WHERE Did = 19; LW anette @ scanned with OKEN Scanner ‘violation error. As there are few employees still working in department with Did =10. UPDATE Department SET Did= 70 WHERE Did = 10; wir ‘Scanned by CamScanner ) DBMS. Seams “ Relational ata i, ‘Output ORA-02292 : integrity constraint (Employee.FK Employee) violated - child to, found = This functionality will creates limitation for updating parent record if it has associated child records. 3. Delate-Update (DU) rules to solve problem of foreign key violation If any row in EMP table is added with ‘Did’ value which is not there in department the insert statement will give foreign key violation error. This rule can be enforced as given below, (@) NO ACTION /RESTRICT ~ This clause will discard the delete or update operation onthe parent table. In this case the database engine will not allow user to delete the row and using Fi violation ror. ~The RESTRICT rule will not allow you to delete a row from the parent table althoug# ‘there is corresponding row present in child table. = Foreign key (Did) references department : © Ondelete RESTRICT © On Update RESTRICT ~The database engine will give the error and the delete action on the row in the put! table is ignored, Deletion of department is not allowed as there is some employees are peesent in ‘Scanned by CamScanner DBMS (MU - Sens. £13 Relatonal Data Model (®) CASCADE = Corresponding rows are deleted from the referencing table (Child table), if that row is deleted from the parent table, ‘ » Foreign key (Did) references department : @ scanned with OKEN Scanner there is corresponding row present in child table. ~ Foreign key (Did) references department : © Ondelete RESTRICT © OnUpdate RESTRICT ~The database engine will give the error and the delete action on the row in the pate table is ignored, ~ Deletion of department is not allowed as there is some employees are present in Scanned by CamScanner DEMS (MU -Sens £13 Relational Data Mode! () CASCADE ~ Corresponding rows are deleted from the referencing table (Child table, if that row is deleted from the parent table, = Foreign key (Did) references department © Ondelete CASCADE © On Update CASCADE ~ If.a department is deleted then all the employee records that refers to the deleted department are also been deleted (© SET NULL ~ Foreign key data value is set to NULL, ifthe corresponding row in the parent table is deleted. ~ For this constraint to execute, the foreign key columns must be nullable. ~ Foreign key (Did) references department: © Ondelete SET NULL © On Update SET NULL, ~ Insert Null value of di in the place of deleted did in employee table, (@ SET DEFAULT ~ Foreign key data values refer to non-existing foreign key are set to their default values ~ Forthis constraint to execute, all foreign key columns must have default definitions. ~ Foreign key (Did) references department: © Ondelete SET DEFAULT © On Update SET DEFAULT Ifa column is null able, and there is no exp implicit default value ofthe column, ~ Insert any default value of ‘did! (which exists in the departing table) in the place of deleted Did. fault value set, NULL becomes the 4. Solteatorontial relations ~ A foreign key constraint can reference some other columns in same tables. ~ It form self-referential relations, For Example, EMPLOYEE (employee_id, employee_name, manager id) Scanned by CamScanner ae Relational Data Moca! @ scanned with OKEN Scanner 48 Mapping Entities to Tables (1) Regular entity types. ~ Tables: Regular entity sets can be represented s table in relational model. = Columns : Attributes of entity set can be converted to, the columns (attributes) of the tables in relational model. : ci Example: Regular entity employee mapped as employee table in object model like ‘Stud id’ ‘Stud_Addr' ete. are shown as table columns, Scanned by CamScanner Deus. 416 Relational Data Model Fig, 48.1 : Regular entity 1 [Snehat | Mumbai 2 | Pratksha | Mumbai 3 [Supriya | Mumbai 4 | Tanmay | Goa (2) Weak entity types For cach weak entity type with owner entity, create a table and include all simple attributes of weak entity type as columns of table, including foreign key attributes as the primary key attribute ofthe table that correspond to the owner entity type. Example Dependents (Weak entity) in Employee (Owner entity). Fig. 4.8.2: Weak entity 1 | Sachin |syoti | 23 2 | Suhas | Manju | 22 3 | Jayendra | Tanya | 27- @ scanned with OKEN Scanner a are In DBMS, efficient query processing is available. MENU © Login In the file system, there is no efficient query processing. In Dbms, there is more data consistency because of the process of normalization. The file system's data consistency is poor. Example: Oracle, MySQL, MS SQL Server, DB2, Example: Microsoft Access, | Cobal,c++ and other databases Conclusion n conclusion, the choice between a File System and a Database Management System depends on the nature and requirements of the data you're dealing with. File Systems are suitable for simple data storage needs, such as documents, images, @ scanned with OKEN Scanner Card MENU Here we have the Difference between File System and DBMS DBMS File System File system is Dbms is a y collection of data or software to store and retrieve the user's data. used to manage and organize the files stored in the computer's hard disk. Dbms gives an abstract view of data that hides the details The file system specifies the details of data representation and storage. Dbms provide a backup means data lost can be recovered In the file system lost data cannot be recovered. The database system is expensive and The file system is cheaper and simple to desian @ scanned with OKEN Scanner The Database Management System (DBMS) architecture shows how data in the database is viewed by the users. It is not concerned about how the data are handled and processed by the DBMS. It helps in implementation, design, and maintenance of a database to store and organize information for companies. The concept of DBMS depends upon its architecture. The architecture can be designed as centralized, decentralized, or hierarchical. The architecture of DBMS can be defined at three levels as follows - External levels. Conceptual levels. Internal levels. The main objective of the three level architecture is nothing but to separate each user view of the data from the way the database is physically represented. The database internal structure should be unaffected while changes to the physical aspects of storage. The DBA should be able to change the conceptual structure of the database without affecting all other users. External level/ View level External level describes a part of the database that is relevant to each user. This level insulates the users from the details of conceptual and the internal level. @ scanned with OKEN Scanner External level/ View level External level describes a part of the database that is relevant to each user. This level insulates the users from the details of conceptual and the internal level. Conceptual level/ logic level Conceptual level describes what data is stored into the database and the relationship among the data It represents the following - All the entities, attributes and their relationships. The constraints on the data Security and integrity information. Internal level/ storage level Internal level is the physical representation of the database on the computer. This level describes how the data is stored in the database. It covers the data structure and file organization used to store the data on storage devices. The levels in the architecture of DBMS are shown below in diagram form - END USERS End user 1 End user 2 End wera EXTERNAL few 1 jew 2 jew LEVEL view view 2 view CONCEPTUAL Conceptual LEVEL Sehema @ scanned with OKEN Scanner Cee ©} = ( Search tutorials, courses and ebook: All the entities, attributes and their relationships. The constraints on the data. Security and integrity information. Internal level/ storage level Internal level is the physical representation of the database on the computer. This level describes how the data is stored in the database. It covers the data structure and file organization used to store the data on storage devices. The levels in the architecture of DBMS are shown below in diagram form - END USERS End user 1 End user 2 End user a EXTERNAL ad ay ; vee view view view NN t a Y CONCEPTUAL ‘Conceptual LEVEL Schema INTERNAL Internal LEVEL Schema ¥ Bhanu Priya @ scanned with OKEN Scanner

You might also like