Docsity

Computer science notes, Study notes of Computer science

Partial preview of the text

Download Computer science notes and more Study notes Computer science in PDF only on Docsity!

COMPUTER SCIENCE

NOTES

GRADE 12

CHAPTER 1

Database Management System(DBMS)

Data The raw facts are called as data. The word “raw” indicates that they have not been processed. Ex: For example 89 is the data. Information The processed data is known as information. Ex: Marks: 89; then it becomes information. Database  It is a collection of interrelated data.  These can be stored in the form of tables.  A database can be of any size and varying complexity.  A database may be generated and manipulated manually or it may be computerized Major uses of database  Storing data  Updating /modifying data  Removing /deleting data  Reduce data redundancy  Improve business processes.  Keep track of customers  Secure personal health information  Store personal data  Data independence  Backup and recovery facilities Field A database field is a set of data values, of the same data type, in a table. It is also referred to as a column or an attribute. Record A record is a collection of items or data that is organized in a group of fields within a table that are related to a specific topic or theme.

Database Management System (DBMS)

 It is a collection of programs that enables user to create and maintain a database.  In other words, it is general-purpose software that provides the users with the processes of defining, constructing and manipulating the database for various applications.

 Universities: registration, grades  Sales: customers, products, purchases  Online retailers: order tracking, customized recommendations  Manufacturing: production, inventory, orders, supply chain  Human resources: employee records, salaries, tax deductions

Objectives of DBMS

 Controlled Redundancy  Ease of Learning and Use  Data Independence  Most Information in Low Cost  Accuracy and Integrity  Recovery from failure  Privacy and Security  Performance DDL DDL is Data Definition Language and is used to define the structures like schema, database, tables, constraints etc. Examples of DDL are create and alter statements. DML DML is Data Manipulation Language and is used to manipulate data. Examples of DML are insert, update and delete statements. Following are the important differences between DDL and DML. Sr. No. Key DDL DML 1 Stands for DDL stands for Data Definition Language. DML stands for Data Manipulation Language. 2 Usage DDL statements are used to create database, schema, constraints, users, tables etc. DML statement is used to insert, update or delete the records. 3 Classification DDL has no further classification. DML is further classified into procedural DML and non- procedural DML. 4 Commands CREATE, DROP, RENAME and ALTER. INSERT, UPDATE and DELETE.

KEY

 A key refers to an attribute/a set of attributes that help us identify a row (or tuple) uniquely in a table (or relation).  A key is also used when we want to establish relationships between the different columns and tables of a relational database.  The individual values present in a key are commonly referred to as key values. Primary Key  A primary key generally focuses on the uniqueness of the table. It is a column or a set of columns that uniquely distinguishes every row in the database.  It means it should not have any duplicate value. Also, it doesn’t contain a NULL value. Foreign Key  A foreign key is generally used to build a relationship between the two tables.  The major purpose of the foreign key is to sustain data integrity between two separate instances of an entity. Difference Between Primary Key and Foreign Key S.No. Primary Key Foreign Key 1 A primary key generally focuses on the uniqueness of the table. It assures the value in the specific column is unique. A foreign key is generally used to build a relationship between the two tables. 2 Table allows only one primary key. Tables can allow more than one foreign key. 3 The primary key doesn’t allow null values. Foreign key accepts multiple null values. 4 It can identify the record uniquely in the database table. A foreign key is a field in the table that is the primary key in another table. 5 In the primary key, the value cannot be removed from the parent table. In this, the value can be deleted from the child table. 6 Its restriction can be completely defined on the temporary tables. Its restriction cannot be defined on the global or local temporary tables. Super Key  A super key refers to the set of all those keys that help us uniquely identify all the rows present in a table. Candidate Key  The candidate keys refer to those attributes that identify rows uniquely in a table. In a table, we select the primary key from a candidate key.

Example: We can represent the relationship between the shoes present on a shopping website in the following way: Features of a Hierarchical ModelOne-to-many relationship: The data here is organised in a tree-like structure where the one-to-many relationship is between the datatypes. Also, there can be only one path from parent to any node. Example: In the above example, if we want to go to the node sneakers we only have one path to reach there i.e through men's shoes node.  Parent-Child Relationship: Each child node has a parent node but a parent node can have more than one child node. Multiple parents are not allowed.  Deletion Problem: If a parent node is deleted then the child node is automatically deleted.  Pointers: Pointers are used to link the parent node with the child node and are used to navigate between the stored data. Example: In the above example the ' shoes ' node points to the two other nodes ' women shoes ' node and ' men's shoes ' node. Advantages of Hierarchical Model  It is very simple and fast to traverse through a tree-like structure.  Any change in the parent node is automatically reflected in the child node so, the integrity of data is maintained. Disadvantages of Hierarchical Model  Complex relationships are not supported.  As it does not support more than one parent of the child node so if we have some complex relationship where a child node needs to have two parent node then that can't be represented using this model.  If a parent node is deleted then the child node is automatically deleted.

Network Model  This model is an extension of the hierarchical model. It was the most popular model before the relational model.  This model is the same as the hierarchical model, the only difference is that a record can have more than one parent.  It replaces the hierarchical tree with a graph. Example: In the example below we can see that node student has two parents i.e. CSE Department and Library. This was earlier not possible in the hierarchical model. Features of a Network Model Ability to Merge more Relationships: In this model, as there are more relationships so data is more related. This model has the ability to manage one-to-one relationships as well as many- to-many relationships. Many paths: As there are more relationships so there can be more than one path to the same record. This makes data access fast and simple. Circular Linked List: The operations on the network model are done with the help of the circular linked list. The current position is maintained with the help of a program and this position navigates through the records according to the relationship. Advantages of Network Model  The data can be accessed faster as compared to the hierarchical model. This is because the data is more related in the network model and there can be more than one path to reach a particular node. So the data can be accessed in many ways.  As there is a parent-child relationship so data integrity is present. Any change in parent record is reflected in the child record.

Graphical Representation for Better Understanding: It is very easy and simple to understand so it can be used by the developers to communicate with the stakeholders.  ER Diagram: ER diagram is used as a visual tool for representing the model.  Database Design: This model helps the database designers to build the database and is widely used in database design. Advantages of ER ModelSimple: Conceptually ER Model is very easy to build. If we know the relationship between the attributes and the entities we can easily build the ER Diagram for the model.  Effective Communication Tool : This model is used widely by the database designers for communicating their ideas.  Easy Conversion to any Model : This model maps well to the relational model and can be easily converted relational model by converting the ER model to the table. This model can also be converted to any other model like network model, hierarchical model etc. Disadvantages of ER ModelNo industry standard for notation: There is no industry standard for developing an ER model. So one developer might use notations which are not understood by other developers.  Hidden information: Some information might be lost or hidden in the ER model. As it is a high-level view so there are chances that some details of information might be hidden. Relational Model  Relational Model is the most widely used model. In this model, the data is maintained in the form of a two-dimensional table.  All the information is stored in the form of row and columns.  The basic structure of a relational model is tables. So, the tables are also called relations in the relational model. Example: In this example, we have an Employee table.

Features of Relational ModelTuples : Each row in the table is called tuple. A row contains all the information about any instance of the object. In the above example, each row has all the information about any specific individual like the first row has information about John.  Attribute or field: Attributes are the property which defines the table or relation. The values of the attribute should be from the same domain. In the above example, we have different attributes of the employee like Salary, Mobile_no, etc.

Advantages of Relational Model

Simple: This model is more simple as compared to the network and hierarchical model.  Scalable: This model can be easily scaled as we can add as many rows and columns we want.  Structural Independence: We can make changes in database structure without changing the way to access the data. When we can make changes to the database structure without affecting the capability to DBMS to access the data we can say that structural independence has been achieved. Disadvantages of Relatinal ModelHardware Overheads: For hiding the complexities and making things easier for the user this model requires more powerful hardware computers and data storage devices.  Bad Design: As the relational model is very easy to design and use. So the users don't need to know how the data is stored in order to access it. This ease of design can lead to the development of a poor database which would slow down if the database grows.  But all these disadvantages are minor as compared to the advantages of the relational model. These problems can be avoided with the help of proper implementation and organisation.

Anomalies in RDBMS In RDBMS several tables are inter-related with each other through table relationship. In such case changing on set of data may directly affect the other set of data. This condition is known as anomalies in DBMS or RDBMS. There are 3 different anomalies that we may encounter while designing a database. They are:  Insertion anomalies : It occurs when data cant be inserted due to absence of other data.  Deletion anomalies : It occurs when we delete one data sets but another data sets gets deleted along with its. Unwanted deletion of data.  Updation anomalies : It occurs when we update a data, but it only gets partially updated through out the several related tables. Advantages of Normalization  It eliminates data redundancy i.e. duplication of data.  It enhances faster sorting and index creation.  It simplifies the complex structure of tables.  It avoid loss of data through consistency and integrity.  It solves insertion, deletion and updating anomalies.  It improves the performance of a system.  The most popular widely used normal forms are:  First Normal Form (1NF)Second Normal Form (2NF)Third Normal Form (3NF)Boyce Codd Normal Form (BCNF)Fourth Normal Form (4NF) Let us consider the un-normalized data attributes. Teacher_Name Subject Age Address Ram Physics Maths 27 Butwal Sita English 25 Palpa Hari Nepali 28 Pokhara 1NF (First Normal Form) Once, we have un-normalized data sets, we arrange then in first normal form by making their each attribute atomic which means in 1NF there should not be repeated data group.

Teacher_Name Subject Age Addresss Ram Physics 27 Butwal Ram Maths 27 Butwal Sita English 25 Palpa Hari Nepali 28 Pokhara

F.The above table is in first normal form 1NF.

2NF (Second Normal Form) After arranging given data sets in 1NF, we eliminate functionally dependent attributes i.e. in this case, Subject depends upon the teacher not on the age and address, similarly age and address also depends upon teacher not on subject. So, in 2NF we remove such functional dependencies by introducing primary key and foreign key. In order to identify records uniquely we assigned a key value which is known as Primary key. Here, we will give unique ID for each teacher. Since, Age and Address depend upon Teacher not on Subject we further break table of 1NF as follows: Teacher_ID Teacher_Name Age Address 1 Ram 27 Butwal 2 Sita 25 Palpa 3 Hari 28 Pokhara Since, Subject depend upon Teacher not on Age and Address, we also already have assigned a primary key for the teacher_name in above table so same, key can be used to link teacher_name with subject. Teacher_ID Subject 1 Physics 1 Maths 2 English 3 Nepali The key which was primary key is now considered as foreign key in this table. In general Foreign key are the same key as the primary key of one table used by several other tables to establish relationship. 3NF (Third Normal Form)

DATABASE SECURITY

 Database security refers to the range of tools, controls, and measures designed to establish and preserve database confidentiality, integrity, and availability.  This article will focus primarily on confidentiality since it’s the element that’s compromised in most data breaches. Database security must address and protect the following:  The data in the database  The database management system (DBMS)  Any associated applications  The physical database server and/or the virtual database server and the underlying hardware  The computing and/or network infrastructure used to access the database Database security is a complex and challenging endeavor that involves all aspects of information security technologies and practices. It’s also naturally at odds with database usability. The more accessible and usable the database, the more vulnerable it is to security threats; the more invulnerable the database is to threats, the more difficult it is to access and use. (This paradox is sometimes referred to as Anderson’s Rule. (link resides outside IBM) Why is it important By definition, a data breach is a failure to maintain the confidentiality of data in a database. How much harm a data breach inflicts on your enterprise depends on a number of consequences or factors: Compromised intellectual property:  Your intellectual property trade secrets, inventions, proprietary practices may be critical to your ability to maintain a competitive advantage in your market. If that intellectual property is stolen or exposed, your competitive advantage may be difficult or impossible to maintain or recover. Damage to brand reputation:  Customers or partners may be unwilling to buy your products or services (or do business with your company) if they don’t feel they can trust you to protect your data or theirs. Business continuity (or lack thereof):  Some business cannot continue to operate until a breach is resolved. Fines or penalties for non-compliance:  The financial impact for failing to comply with global regulations such as the Sarbannes-Oxley Act (SAO) or Payment Card Industry Data Security Standard (PCI DSS), industry-specific data privacy regulations such as HIPAA, or regional data

privacy regulations, such as Europe’s General Data Protection Regulation (GDPR) can be devastating, with fines in the worst cases exceeding several million dollars per violation. Costs of repairing breaches and notifying customers:  In addition to the cost of communicating a breach to customer, a breached organization must pay for forensic and investigative activities, crisis management, triage, repair of the affected systems, and more. Data protection tools and platforms  Today, a wide array of vendors offers data protection tools and platforms. A full-scale solution should include all of the following capabilities: Discovery:  Look for a tool that can scan for and classify vulnerabilities across all your databases whether they’re hosted in the cloud or on-premise and offer recommendations for remediating any vulnerabilities identified.  Discovery capabilities are often required to conform to regulatory compliance mandates. Data activity monitoring:  The solution should be able to monitor and audit all data activities across all databases, regardless of whether your deployment is on-premise, in the cloud, or in a container.  It should alert you to suspicious activities in real-time so that you can respond to threats more quickly.  You’ll also want a solution that can enforce rules, policies, and separation of duties and that offers visibility into the status of your data through a comprehensive and unified user interface. Make sure that any solution you choose can generate the reports you’ll need to meet compliance requirements. Encryption and tokenization capabilities:  In case of a breach, encryption offers a final line of defense against compromise.  Any tool you choose should include flexible encryption capabilities that can safeguard data in on-premise, cloud, hybrid, or multicloud environments.  Look for a tool with file, volume, and application encryption capabilities that conform to your industry’s compliance requirements, which may demand tokenization (data masking) or advanced security key management capabilities. Data security optimization and risk analysis:  A tool that can generate contextual insights by combining data security information with advanced analytics will enable you to accomplish optimization, risk analysis, and reporting with ease.

 The design is further used by developers and development DBAs to design and implement real application. OLAP DBA  They design and builds multi-dimensional cubes for determination support or OLAP systems. Importance of Database Administrator (DBA)  Database Administrator manages and controls three levels of database like internal level, conceptual level, and external level of Database management system architecture and in discussion with comprehensive user community, gives definition of world view of database. It then provides external view of different users and applications.  Database Administrator ensures held responsible to maintain integrity and security of database restricting from unauthorized users.  It grants permission to users of database and contains profile of each and every user in database.  Database Administrator also held accountable that database is protected and secured and that any chance of data loss keeps at minimum. Role and Duties of Database Administrator (DBA) Decides hardware They decides economical hardware, based upon cost, performance and efficiency of hardware, and best suits organisation. It is hardware which is interface between end users and database. Manages data integrity and security Data integrity need to be checked and managed accurately as it protects and restricts data from unauthorized use. DBA eyes on relationship within data to maintain data integrity. Database design DBA is held responsible and accountable for logical, physical design, external model design, and integrity and security control. Database implementation DBA implements DBMS and checks database loading at time of its implementation. Query processing performance DBA enhances query processing by improving their speed, performance and accuracy. Tuning Database Performance If user is not able to get data speedily and accurately then it may loss organization business. So by tuning SQL commands DBA can enhance performance of database. THANK YOU