The words you are searching are inside this book. To get more targeted content, please make full-text search by clicking here.

[UNOFFICIAL] BUKU TEKS SAINS KOMPUTER TINGKATAN 5 DALAM BAHASA INGGERIS (AUTO-TRANSLATE)

Discover the best professional documents and content resources in AnyFlip Document Base.
Search
Published by Tunku Irfan, 2023-08-18 16:53:42

[BAHASA INGGERIS] BUKU TEKS SAINS KOMPUTER TINGKATAN 5

[UNOFFICIAL] BUKU TEKS SAINS KOMPUTER TINGKATAN 5 DALAM BAHASA INGGERIS (AUTO-TRANSLATE)

Keywords: sains komputer,buku teks sains komputer,sains komputer buku teks,buku teks sains komputer tingkatan 5,sains komputer tingkatan 5

Example 2 shows a truth table for TWO input variables (A and B) with four possible combinations of binary input values (0, 1). Example 3 shows a truth table for THREE input variables (A, B and C) with eight possible combinations of binary input values (0, 1). Example 1 shows a truth table for ONE input variable (A) with two probabilities of binary values (0 and 1). EXAMPLE 3 EXAMPLE 1 EXAMPLE 2 INPUT INPUT INPUT CHAPTER 1 Computing 43 0 1 0 0 1 A 1 0 1 1 0 0 1 1 1 1 B 1 0 1 1 0 0 0 0 1 0 1 0 0 1 A 1 0 A C 0 B 1 0 Machine Translated by Google


Gate symbol Permission Table AND Boolean expressions Example 4 shows a truth table for FOUR input variables (A, B, C and D) with 16 possible combinations of binary input values (0, 1). A X B F = A + B Read: A OR B Gate name F = A . B A AND B OR Read: Table 1.3.5 shows the formulation of logic gates together with Boolean expressions and truth tables. F B B13-20 A EXAMPLE 4 INPUT 44 Computer Science Form 5 F OUTPUT Table 1.3.5 Summary of logic gates with Boolean expressions and truth tables INPUT INPUT A B13-19 B OUTPUT 1 0 1 0 1 0 0 0 1 0 1 1 A 0 1 1 F 0 1 0 0 1 0 1 C 0 0 0 1 0 1 1 1 1 1 A 1 0 1 0 B F 1 1 D 0 0 1 1 0 0 1 1 0 0 0 1 1 1 1 1 0 1 B 0 0 1 1 0 0 1 B 0 0 1 0 1 0 1 1 0 0 0 0 1 0 1 1 1 0 0 0 1 0 0 1 A 0 Machine Translated by Google


F B13-24 A B B F B13-25 A INPUT INPUT OUTPUT OUTPUT CHAPTER 1 Computing 45 INPUT INPUT OUTPUT OUTPUT OUTPUT INPUT A A B F B13-22 B F B13-23 Boolean expressions A NOT Gate symbol Permission Table F = NO AND NO OR F = (AB) Gate name – XATAU XTAKATAU NO OR F = A B Read exclusively OR The output from XATAU is reversed because of the bar sign A – Read exclusively F = F has the opposite (inverter) value to A If both inputs have the same value, an output of '0' will be produced. 0 F = A B 0 0 0 0 0 0 A 0 0 0 0 0 1 A 0 1 1 0 1 B 1 1 0 0 0 1 1 1 1 1 B.A. B F = (A .B) 1 1 0 BA + B F = A + B 1 A 0 Read: A AND 0 0 0 1 0 Read: A OR 1 0 0 1 1 1 F 1 1 0 F BA BF 1 B bar 1 0 1 A 1 1 B bar 1 1 1 1 1 0 0 0 0 A 0 1 A F Machine Translated by Google


In learning standard 1.3.3, students have learned how to build truth tables for basic logic gates and combinational logic gates. In learning standard 1.3.4, learning will continue by building a truth table for a logic circuit that combines various types of gates. Example 5 shows how to build a truth table for a two-input combinational logic gate circuit. (b) Redraw the basic gate symbol shown in (a). Given a logic circuit with two inputs, namely A and B as in the following figure. The following diagram shows a combination of several types of logic gates. Logic Gate (a) Determine the number of basic gates involved. (c) Write a Boolean expression to represent the outputs F1 and F2. A B B A 46 Computer Science Form 5 1 F2 Q P F1 F 0 EXAMPLE 5 Individual Work ACTIVITY 2 1.3.4 Constructing a Truth Table for a Two-Input Combined Logic Gate Circuit Machine Translated by Google


A 1 0 0 A Table 1.3.6 Permission table Q CHAPTER 1 Computing 47 Q = 1 F F B P P P = 1 0 1 B Q A OUTPUT 0 A 1 1 Step 4: P value = 1. Step 1: A 1 0 0 In summary, the truth table for the logic circuit of two input variables A and B produces 22 = 4 probability combinations of input values as shown in Table 1.3.6, which is the truth table. P 1 1 Get TAK DAN 1 Input A = 0 through the TAK gate will produce the inverse value, which is Q = 1. F = AB + A 1 0 Get NO Get OR Step 2: B 1 INPUT 0 After going through the NOT AND gate, that is 1 X 0 = 0 (0 spread) will produce 1. 1 0 0 The input of P = 1 and Q = 1 through an OR gate makes F = P + Q = 1 + 1, the nature of the OR gate if one of the inputs through it is 1 or both inputs are 1, then output = 1 will be produced, thus output at F = 1. Suppose the input value of A is '0' and B is '1'. A.B 1 1 Q Step 3: 1 0 Machine Translated by Google


Guide: Individual Work B OUTPUT/Get 4 The following diagram shows a logic circuit consisting of logic gates as shown in Table 1.3.5. Logic Gate A INPUT Gate 1 Gate 2 Gate 3 1 1 0 1 1 0 0 0 F = This topic will show how to construct a Boolean expression for a combinational logic circuit that has two inputs as shown in Figure 1.3.3. 1.3.5 Constructing a Boolean expression for a Two-Input Combined Logic Gate Circuit ACTIVITY 3 Gate 2 B Gate 3 Q B A 48 Computer Science Form 5 Part 3 Gate 1 Figure 1.3.3 Two-input logic circuit Part 2 F Part 1 Gate 4 F A P (a) Name the gates marked Gate 1, Gate 2, Gate 3 and Gate 4. (c) Complete the following truth table with the values produced by the logic circuit shown. (ii) Write the form of the Boolean expression after going through each gate specified in (i). (b) Show the steps to obtain the output of each gate specified in (a). Answer the following questions based on the logic circuit shown. (i) Name Gate 1, Gate 2, Gate 3 and Gate 4. Machine Translated by Google


CHAPTER 1 Computing 49 F Gate 4 Gate 1 A Gate 3 Gate 2 B Individual Work Pupils need to divide the circuit into three parts based on the logic gates involved. B. The output produced by the TAK gate at P is B. – Part 1: Involving the TAK logic gate. The input for this gate is only one, ie The following steps need to be done to determine the output form at each output at P, Q and finally the output to the circuit, which is F. The Boolean expression for the logic circuit above can be written as follows: The variables that represent the inputs of this logic circuit are A and B. B+A. Part 3: Q and A are inputs to an OR gate. This gate will produce an output, which is F = Q + A, read Q OR A, Q is replaced with the result of part 2 of F = A. B, can also be called A times B bar. B+A Part 2: A and P are inputs to the AND gate, This gate produces an output, which is Q = A AND P or written as Q = AP, replace P with B, which is the result of part 1 Q = A. F = A. – – – – Show how to get the expression at each gate passed. Write a Boolean expression in F, which is the final result of the logic circuit above. Logic Gate The diagram below shows a logic circuit, which is a combination with two inputs, namely A and B. ACTIVITY 4 Machine Translated by Google


B B13-33 B B13-32 50 Computer Science Form 5 B13-31 B A B A A A 1.3.6 Building Logic Gate Circuits and Truth Tables – B). – Step 3: B – and one AND gate for Given a logical statement or Boolean expression as follows: Count the number of variables or inputs involved. produce linking ( Step 2: Value F = 1 if (A = 0 AND B = 0) or (A = 1 AND B = 1) or Solution: Only one gate is involved, which is the AND A and B are the two input variables to the circuit. gate to connect (A AND B). – For the expression A– B, determine the gates involved. For expressions involved. To build a logic gate circuit, you need to divide the expression into three parts. The following steps need to be done: The two gates involved, namely a TAK gate to change input B to connect (A AND – A, – Step 1: Three gates are involved, namely two TAK gates For the expression AB, determine the gate involved. Students have learned the concept of logic gate circuits, namely how to build a truth table and how to build a Boolean expression, now students will learn how to build a logic gate circuit if given a logic statement or Boolean expression. The following example shows the steps that need to be taken if the student wants to build a logic circuit based on a logic statement or Boolean expression. – A– B+ AB + A– B (Boolean expression form) or B and one AND gate for F = B). Step 4: – A– B, determine which gate (A = 1 AND B = 0) (Logic Statement form) A AND Solution: Solution: Solution: Machine Translated by Google


B + AB + A– B – F = – All three expressions, namely from steps 2, 3 and 4 are connected with an OR gate. Combine all three figures. The following circuit results from the given Boolean expression. Next, build a truth table for the obtained circuit. Make each input variable and each logical statement resulting from each gate the name of a truth table field. Output As a summary, students will learn how computer engineering experts build logic gate circuits for integrated circuit devices loaded inside processor chips. Example 6 shows the use of a logic gate circuit to solve a problem. The value that changes after passing through the gates Step 5: OR gate Table 1.3.7 shows the truth for the generated circuit. A Input Permissions and Boolean Expressions for Solving Problems A F B CHAPTER 1 Computing 51 Table 1.3.7 Permission table Individual Work 0 0 0 0 AB – 0 0 0 0 0 0 A 0 0 1 0 – A F 1 A 0 0 – 1 0 1 1 – B B 1 1 B 1 A 1 0 0 1 1 – B 1 1 1 (a) Output value F = 1, if (input value of A = 0 OR input value of B = 0) OR (input value of A = 1 AND value of B = 0). Logic Gate Circuits and Truth Tables Draw a logic circuit diagram and construct a truth table to represent the following Boolean expression or logic statement: (b) Q = (– A .– B) + (A•B) 1.3.7 Production of Logic Gate Circuits, Table ACTIVITY 5 Machine Translated by Google


ACTIVITY 6 You Did you know? EXAMPLE 6 circuit if necessary, that is by using gategate replacement. F B A used to facilitate the size and shape modification process but produces the same output. 52 Computer Science Form 5 Boolean expression B Permission table Equation or A For example, if the circuit uses basic AND gates, NOT and OR gates can be replaced with NOT AND or NOT OR gates A. B Equivalent to 1 0 0 0 1 Step 1 : Write a logical expression to represent the given scenario. Output 0 1 (siren sounds) If A = ON and B = OFF and C = OFF or If A = OFF and B = OFF and C = ON Answer all of the following questions: F = AB + 1 (siren sounds) 0 Step 2 : Rewrite it as a Boolean expression. 0 0 1 – A. – B Step 3: Draw a logic gate circuit diagram to represent the Boolean expression in step 2. Logic Gate Circuits, Truth Tables and Boolean Expressions 1 Write a Boolean expression for the logic statement given in the table above. 3 Construct a truth table to test the truth of the output of the logic gate circuit in question (2). Signal Light Output 0 A 1 0 Transition – B A.– B 1 0 If A = OFF and B = ON and C = OFF or 0 F = 1, if (A = 1 AND B = 1) OR (A= 0 AND B = 0) – A. – B Example 6 describes the steps to be taken to build the logic circuit of the alarm system. The alarm system is built using two input logic circuits, namely A and B. The system will emit a sound signal, F, if the input of A represents ON and the input of B represents ON, or if the input of A represents OFF and the input of B represents OFF. Based on the given situation, students have to write logical expressions to represent the given scenario. The following steps must be followed by students. 0 F = 1 2 Build a logic gate circuit to represent the resulting Boolean expression. AB F = AB + Input Step 4 : Construct a truth table for the two input variables. 1 Requirement A A + B = A . B B The traffic light system uses three inputs to its logic circuit. The following table shows the conditions for the circuit to produce an output to the traffic light. Individual Work Machine Translated by Google


strengthening exercises 1.3 A B Output A B Output Output Output A A B CHAPTER 1 Computing 53 B Output A B 0 1 1 Output 0 Output A B 1 (a) Name the gates in (b)(i) to (b)(vi). 0 1 (iii) A 0 1 0 B Output 1 A 0 (ii) 1 0 B 1 A 0 B (iv) 1 Based on the given logic gate diagram: (b) Complete the permission table provided for each of the following gates. 1 (v) 0 (i) Output A 0 B (v) 0 1 Output 0 1 1 Output A B Output ) A B 0 0 0 1 1 1 1 1 0 0 0 0 1 1 1 0 1 0 0 0 1 1 1 0 Machine Translated by Google


B B 54 Computer Science Form 5 A A B B A A A A B (b) A B (a) B A F , Gate 1 Gate 4 (NOT) Gate 2 4 The XATAU gate (exclusive OR) only allows the combination of the two inputs 2 Based on the given logic gate diagram, match the logic gate on the A side which (NOT OR) Terminology 0 0 Write your answers to parts (i), (ii), (iii) and (iv). for Section A 0 Gate 3 5 An integrated circuit (IC) is an electronic circuit that consists of a combination of components and (a) (iii) Section B 0 1 input is A. , (c) which is necessary to implement (b) Specify a value of either 0 or 1 for each gate output specified in the following truth table. 6 Based on the following logic gate circuit diagram, answer the given questions. 1 A get output 0 (OFF). (a) State the expression produced by each gate. the output is equivalent to the logic gate on the B side. (i) (OR) 1 (ii) 1 (NOT AND) (b) 3 The following diagram shows the connection of two TAK gates. State the output in (a) and (b) if electronic multi-function logic gate. B (i) (ii) (iii) F=(iv) Machine Translated by Google


Machine Cycle • Structured Build a Schedule Publish the expression Data and network security Innovation in Level Language 2 Decode Device Unit Cyber crime Network Computers and • Assembly language • Machine language Impact Technological Innovation Social implications Career opportunities Input and Introduction to Logical Gates Generate Logic Circuits Computer Processor Programming Language Processing Contribute to existence Online • Object-based and visual Memory Unit Unethical issues Effect Center 1 Achieve Output Truth Low Computing Technological Innovation Technological Innovation Cyber law 3 Execute Boolean Software Device COMPUTING System Storage Computer architecture Units High Level Language Integrated Circuits/chips RESCAN CHAPTER 1 Computing 55 Machine Translated by Google


56 Computer Science Form 5 9 The components in the computer are connected by electronic lines called (i) Data bus (ii) Address bus (iii) Control bus cyber crime is 3 Piracy and hacking activities are prosecutable offences . 1 The processor performs the processing of data and instructions according to the steps in the machine cycle. There are three main steps in the machine cycle that the processor will repeat until the data and instructions are finished processing and sending the output to the main memory. whose values for w, x, y and z are . With the help of a machine cycle diagram, briefly explain how data and instructions are processed. 4 Logic gates to code by the processor. produces an output of 0 when both inputs are equal. . . , 2 6 Instructions such as MOVE or DIV are instructions in the language as a bus. State the function of the following bus: 7 In Malaysia, two government bodies that monitor, curb the spread and enact acts components in the processor (CPU). , Act 8 The following table shows the truth table for the XTAKOR (exclusive-NOT-OR) gate 1 The purpose of translator software is to convert language program code which is understood by the computer before the program code is processed 5 is one of the components in the processor (CPU) that functions to decode instructions to determine the type of operation that will be performed by the Arithmetic and Logic Unit (ALU). is the fastest memory in the memory hierarchy which is one of and and Section A Section B enrichment exercises 1 1 0 0 1 w Z 0 y 1 0 x Input Output 1 Machine Translated by Google


B C CHAPTER 1 Computing 57 A X Sainskomptg5.com/ bab1/ LTB1 You can access the QR code shown to get the Chapter 1 Drill. computer. Plain text: (b) Exclusive gate OR 4 The following messages will be decoded: 3 Give three unethical activities that students might do while using (a) Gate NOT OR 9 Draw a logic circuit diagram to represent the following Boolean equation. Q = ABC + A( 2 Briefly explain the impact of innovation in computing that affects the existence of the Internet of Things. 6 Draw the gate symbol and construct a truth table with two inputs for the gate type as follows. 5 State the three components of a processor and explain the function of each component. Cipher text: – After the encryption process with displacement, (n = 3), rewrite the representation of the decrypted message. – Q = ABC + (ABC) B+ • DECODE DATA FOR SECURITY 7 Construct a truth table for the following Boolean expression. 8 Write a Boolean expression for the output produced by the following circuit. C) Machine Translated by Google


• If there are thousands of students in your school, can you imagine how to quickly find a record of a student? •What is an easy and fast way to save and access records? Think... Machine Translated by Google


• Entity Relationship Diagram •SQL: Manipulating Data (Entity Relationship •SQL: Accessing Data In this chapter, you will learn: Diagram - ERD) •Aggregate Functions •Data Relationship Model • Build a Database Data •SQL: Building a Base Extension Chapter 2 Database such as schools, universities, libraries, banks, supermarkets and tourism always interact with data. Do you know where a student's data is stored? With sophistication The use of information technology is currently becoming more widespread In today's information technology, all data is stored in a database. Data is the lifeblood of an organization. Base and important in human daily life. Environment and access data from anywhere in the world using computers, smartphones and tablets. data can help an organization be more manageable in order to increase productivity. You can now save Machine Translated by Google


Learning Standard 2.1.1 Entity Relationship Diagram (Entity Relationship Diagram - ERD) Mind Test Query Language (Structured Query language) Structured: SQL The existence of weak entities depends on strong entities. Example: STUDENT, TEACHER, COURSE. A strong entity can exist without relying on other entities. STUDENTS A database is a collection of related data that can be shared by various categories of users. Examples of database applications are Book Loan System, Student Information System, Ticket Reservation System and so on. Before developing a database system, you need to identify the problems of the existing system first. You need to know and understand the processes and data flows in the existing system. The solution to the problem can be illustrated using an Entity Relationship Diagram (ERD). An entity relationship diagram is the basic model in building a database. ERD is a technique used to model the data needed in an organization. ERD also describes the concept of database structure. There are three basic components in ERD, namely entities, attributes and relationships. There are two types of entities, namely: An entity is a unique and identifiable object or concept in a particular environment such as a person, place, thing or event that is collected and stored as data. Examples of entities are STUDENT, TEACHER, BOOK, EXAM. Entities are represented in rectangular form as follows: •Weak entities •Strong entity 2.1 2.1.2 Produce a normalized relationship scheme (normalize) from the given problem 2.1.6 Using AVG, SUM, MAX, MIN and COUNT functions At the end of learning students can Give another example 60 Computer Science Form 5 2.1.7 Build a relational database using SQL to solve problems for database system applications you know. 2.1.3 Build a relational database using SQL: Table 2.1.1 Draw an ERD (Entity Relationship Diagram) for the given problem 2.1.5 Using SQL SELECT to retrieve data by using GROUP BY and ORDER BY 2.1.4 Using SQL to manipulate data such as insert/add, delete and update Entity Relationship Diagram Structure Machine Translated by Google


Weak relationship Weak Entity Identification card number My Malaysia! Name Entity Attributes Attributes Attributes Staff Identification Card Number, Name, Date of Birth, Address dependants Entity Staff No., Teacher's Name, Salary, Skills STUDENTS have students TEACHER Example: DEPENDENCY. DEPENDENT entities will only exist if there are STAFF. Weak entities are represented in the form of a rectangle with two lines as Figure 2.1.1. Attributes are properties that describe a set of entities. Attributes are represented in oval form. Figure 2.1.2 shows the representation of attributes in ERD. Examples of attributes are shown in Table 2.1.1. Weak ties are used to unite strong entities and weak entities. Weak ties are represented in the form of double-lined gems. Attributes or fields are characteristics that describe an entity. 2007, this award was replaced by Table 2.1.1 Attributes Quality Award This award is a recognition and appreciation given to an organization that shows excellence in the implementation and effective use of information technology and In 1999, the Prime Information Technology Award (APTM) was introduced. Figure 2.1.2 Attribute representation in ERD Information and communication technology (AIICT). CHAPTER 2 Advanced Database 61 Figure 2.1.1 Weak entities (AKICT). In 2010, AKICT was replaced by the Information and Communication Technology Innovation Award PICOM In the year communication. This award is organized by MAMPU, the Prime Minister's Department and Machine Translated by Google


Chen is the founder of Entity Relationship Diagram (ERD). He founded it in the 1970s. ERD Figure 2.1.3 Types of attributes is still used today and is said to be an almost verbose way of expressing relationships between entities. What is on Entity Relationship Table 2.1.2 Attribute notation 62 Computer Science Form 5 Give the ERD notation for the STUDENT entity that has gender and age attributes. goo.gl/ dcGyEC Who is Dr. Peter Chen? Dr. Peter Mind Test Simple attributes Example: Identity Card No. A composite attribute is an attribute that can be broken down into multiple parts. City Attributes Description Example: Skills Attributes section. Key attribute Example: Annual Salary Attributes Postal code publication Key attributes are unique. This attribute distinguishes each record in Attributes the database. Attributes •Single-valued attributes have only one value. Notation A multiple value attribute has more than one value. Example: An address can be divided into Street, City and Postcode Address Attributes This notation is used to represent simple attributes and singlevalued attributes A teacher has more than one skill. Road Multiple value attribute •Simple attributes cannot be divided into several Composite attributes This output attribute is generated based on other attributes. single value Attributes Example: Identification Card Number and Personnel Number Example: Name, Identity Card No. The annual salary of a teacher is obtained by calculating the monthly salary × 12 months Table 2.1.2 explains the types of attributes and their characteristics. There are six types of attributes as shown in Figure 2.1.3. Did you know? You Machine Translated by Google


subject My Malaysia! relationship teach teacher A relationship is a union between entities. In an ERD, there are many entities that have relationships with each other. Because of this, relationships are used to unite one or more entities present in the ERD. A relationship shows how two entities share information in a database. Relations are labeled with verbs. Examples: teaching, registering and staying. A primary key is a unique attribute that distinguishes records in a database. Each entity has only one primary key. Cardinality shows the relationship in terms of data quantity between an entity and another entity. There are two types of cardinality, namely: A TEACHER teaches at least one SUBJECT. An example of the primary key for the STUDENT entity is Identification Card No and the primary key for the TEACHER entity is Staff No. •Maximum Cardinality •Minimum Cardinality Relationships are represented in the form of gems as in Figure 2.1.4. NoKadPengelanan is unique because a student only has one NoKadPengelanan and the number is different from other students. Maximum data of an entity related to other entities. Example: A COURSE can be taught by one or more TEACHERS. A teacher can teach a maximum of more than one subject. Then the maximum cardinality is many. Minimum data of an entity related to other entities. Example: Suppose there are two entities, namely TEACHER and COURSE. A TEACHER teaches at least one SUBJECT. So the minimum cardinality is one because a teacher must teach at least one subject. There is no teacher who will not teach. No student has the same Identity Card No. In ERD, primary keys should be underlined. Figure 2.1.4 Relationship goo.gl/ 9G641p Cardinality goo.gl/ qaVHPB CHAPTER 2 Advanced Database 63 ER Model On 26 October 2016, Prime Minister Dato' Sri Najib Tun Razak urged local digital sector activists to collaborate with the global technology community because Malaysia will reap great benefits if the potential of the digital economy is fully exploited. The government announced that 2017 is Malaysia's Year of the Internet Economy. Machine Translated by Google


Mandatory One Maximum cardinality Optional One Mind Test The minimum of data is empty and the maximum of data is one. The minimum of data is empty and the maximum of data is many. teacher Description Many Optional subject The minimum and maximum of the data is one. teach Many Mandatory Minimum cardinality Symbol The minimum of data is one and the maximum of data is a lot. ÿ Identify all related entities and relationships between entities. ÿ Use color Table 2.1.3 Cardinality relationship ÿ Each entity only appears once in a diagram. interesting color. Suppose there is a STUDENT and a CLUB. A STUDENT can register at least one CLUB. One CLUB can be registered by more than one STUDENT. ÿ Use names Figure 2.1.5 Cardinality relationship 64 Computer Science Form 5 which is appropriate for entities, attributes and relationships. Tips for drawing an ERD. entity. Based on Figure 2.1.5, build an ERD that represents the situation as below. ÿ Eliminate overlapping relationships between Did you know? You Table 2.1.3 shows the types of cardinality relationships and their characteristics. ERD in Figure 2.1.5 means that a teacher should teach at least one subject and the maximum number of subjects that can be taught is two or more. While subjects must be taught by at least one teacher and the maximum number of teachers who can teach a subject is two or more. Figure 2.1.5 shows the cardinality relationship. Machine Translated by Google


Entity Attributes Cardinality Mind Test Relationship Draw an ERD (Entity Relationship Diagram) •GOODS are stored sports equipment. Item attributes are Item No, Item Name, Quantity, Unit Price. Stock management and inventory of sports equipment is very important in the success of a sports and co-curricular activity. The lack of sports equipment makes a sport difficult to carry out. The sports store database contains records of various sports equipment either for school sports or for learning and teaching Physical Education subjects. In this database also, information on sports goods, suppliers, borrowers and loan records made by all students are stored. The entities involved are as follows: Figure 2.1.6 shows an example of the representation of entities, attributes, relationships and cardinalities in ERD. •MURID is a borrower of sporting goods. Student attributes are student id, student name and class. Road students City Teacher's name Figure 2.1.6 Example of representation of entities, attributes, relationships and cardinality in ERD register Subject Microsoft Visio for drawing ERDs Based on Figure 2.1.6, build an ERD that shows the representation of entities, attributes, relationships and cardinalities for TEACHER, CLASS and SUBJECT Good luck! goo.gl/ c8eylD Name teacher ER Diagram Tutorial Identification card number Address No staff goo.gl/ I1JAuA Postal code Name of the subject teach Skills CHAPTER 2 Advanced Database 65 Code No Machine Translated by Google


Did you know? You Entity Attributes The relationships and cardinalities between entities are as follows: •LOAN is the state of occurrence of the borrowing process. Attributes •Each sports item can be borrowed by one student at a time 2 Identify the primary key. loan is Loan No, Loan Date and Return Date. time. Each student can borrow one or more sports items. •A student can make one loan or not make one 3 Identify relationships between entities: any loan. Each loan records the loan data made by one student at a time. • borrow •SUPPLIERS are individuals or companies that supply sporting goods. •Each supplier can supply one or more goods and each • record goods may be supplied by one or more suppliers or not supplied by any supplier. Supplier attributes are SupplierNo, SupplierName and Address (consisting of Street Name, City, Postcode and State). • supply The steps to sketch the ERD are as follows: 4 Sketch the ERD and identify the cardinality as in Figure 2.1.7. 1 List the entities and attributes. What is a primary key? Let's recall our learning about primary keys in Form 4. A primary key is an attribute or a combination of several attributes with a unique value to represent each record in a table. 66 Computer Science Form 5 SupplierNo, SupplierName, Address (is a composite attribute consisting of StreetName, City, Postal Code, State) Item No SUPPLIERS students ITEM Loan No STUDENTS Entity Supplier No LOAN ITEM STUDENTS LOAN Item No., Item Name, Quantity, Unit Price idmurid, Student Name, Class SUPPLIERS Loan No., Loan Date, Return Date Primary Key Machine Translated by Google


Return date Quantity SUPPLIERS CHAPTER 2 Advanced Database 67 Students name The unit price Address Student ID record City Item No supply Loan No Item name LOAN Street Name STUDENTS Supplier No state ITEM Postal code Supplier name borrow Borrow Date Figure 2.1.7 ERD inventory management system Class Machine Translated by Google


1 Identify the following components of an entity relationship diagram: Identify the Components of an Entity Relationship Diagram 2 Draw an entity relationship diagram (ERD). • Entities My Malaysia! •Attributes You have been assigned to build a database system for Sri Inai Hospital. This system aims to record the information of outpatients who have received treatment at the hospital in question. This system can also help the hospital access and store patient data quickly and efficiently. •Relationship Based on the results of your visit and observation to the hospital in question: The first step you need to do is identify the data you want to store in the database. 2.1.2 Data Relationship Model Individual work ACTIVITY 1 initiated projects Malaysia (KPM) and implemented in collaboration with YTL Communications. This project has a positive impact in the long term to help students by the Ministry acquire 21st century learning skills, bridge the digital divide and realize the concept of technology for all thus changing the lives of people, especially those who live far away in suburban areas. A total of 10,000 primary schools and schools 68 Computer Science Form 5 secondary schools in Malaysia will be equipped with 4G highspeed Internet access and a virtual learning platform that provides high-speed Internet connection as well as access to Integrated Learning Solutions. Education Source: 1BestariNet is http:// 1bestarinet.net/ The data relation model was introduced by EF Codd in 1970. Most database management systems such as MS Access, Oracle and My SQL uses this model. This model stores data in the form of relational tables, that is, data and relations are presented in the form of tables. This model is built as the next step after you sketch the Entity Relationship Diagram. A data relation model can give you an idea of the table structure for the database system you want to develop. Machine Translated by Google


Application Daily Mind Test STUDENT (Identity Card Number, Name, Address) and Malay, CHAPTER 2 Advanced Database 69 English, EF Codd is known as the Father of Database Systems. He has put forward 12 principles about databases. Mathematics and The "MindAppz" and "Kingaroo" applications are the first education-based mobile applications for students at the primary and secondary levels in Malaysia. This application includes Malay, English, Mathematics and Science History for high school. for primary school One of the differences between primary keys and foreign keys is that primary keys cannot accept null values, unlike foreign keys. State three other differences between primary keys and foreign keys. COURSE (Code Number, Subject Name) STUDENT (Identity Card Number, Name, Address, Code Number) Contact Key You Did you know? Characteristics of the Data Relationship Model First Normalized Form (1NF). •Each record is different. •Each attribute (field) has a different name. The data relationship model in Figure 2.1.8 shows the relationship between STUDENTS and SUBJECTS. Each table must have a primary key. In the STUDENT table, the primary key is NoKadPengelanan while NoKod is the primary key of the COURSE table. A foreign key is required to link these two tables. Here, the foreign key is the NoCode found in the STUDENT table. An example of a data relationship model is shown in Figure 2.1.8. A foreign key is a primary key of a relation that appears in other relations in the same database. This key is marked with a dashed line. Foreign keys are used to link between two tables. For example between STUDENT and COURSE: Every relationship should have a primary key that allows you to store and access the data in the relationship. A primary key is a unique attribute (either one or several attributes) chosen to identify records in a relationship. The primary key should be outlined as in the following example. •The order of attributes (fields) has no importance. •Each relationship (table) has a different name than •The order of the records has no significance. other contact names. A relation is a table consisting of records and fields. However, not all tables are relations. Relationships have certain characteristics such as the following: Relationships that have the above characteristics are called normalization or •Each data in a relation has only one value. Example: Machine Translated by Google


ÿ Do not have repeating groups Figure 2.1.9 Steps to map ERD to relational schema Identification card number 70 Computer Science Form 5 The conditions are: Name Figure 2.1.8 Data relationship model On 25 August 2015, the Ministry of Science, Technology and Innovation launched the Big Data IoT Technology Accelerator (BITX) laboratory What conditions satisfy the First Normalized Form (1NF)? Address ÿ Has an indivisible value to provide services and technology related to the Internet of Things (IoT) Industry. IoT refers to the result of the convergence of various technologies from wireless communication to the Internet. A data relation model contains a set of normalized relations. The attribute will be the name of the field Entities are converted to relationship names The database structure is shown in the form of a schematic that describes the overall logical structure of a database. The steps of mapping the ERD to the relational schema are as shown in Figure 2.1.9. The type of relationship in the ERD will determine the selection of foreign keys STUDENTS Example: Did you know? Relationship Schema You Mapping ERD to Relationship Schema Iris Amir TA03 TA01 STUDENTS Naufal TA02 Identification card number Address Kelana Jaya TA03 SUBJECT 991002021111 990203042222 Shah Alam PJ 990110105555 Code No No_Code My Malaysia! TA01 Name Malay TA02 Name Mathematics History Machine Translated by Google


EXAMPLE 1 principal school School No manage Address ID no Name of School Name Solution: School No Name of School ID no Figure 2.1.10 ERD shows a 1 to 1 relationship ID no Name Table 2.1.4 1 to 1 relationship scheme Address CHAPTER 2 Advanced Database 71 SCHOOL The foreign key must be selected from the entity side that is on the mandatory side. The entity on the mandatory side is the PRINCIPAL. Therefore, NoID will be a foreign key in the SCHOOL table as in Table 2.1.4. THE PRINCIPAL Example 1 shows the steps to map an ERD to a relational schema. You need to consider the types of relationships present in the ERD to define foreign keys. 1 One-to-one relationship like Figure 2.1.10 •One-to-many relationship Among the types of relationships in ERD are: •Many-to-many relationship •One-to-one relationship Machine Translated by Google


customer make raw material order Address Supplier No Order Date Customer No Address Name Cost Name Material No Order No TotalUnits supplier supply Solution: CUSTOMERS In a one-to-many relationship, the primary key on the one side will be the foreign key on the many side. Because of this, CustomerNo will be a foreign key in the ORDER table as in Table 2.1.5. ORDER Mind Test Order Date Customer No Entity-Relationship Customer No Model Name Figure 2.1.11 ERD shows the 1 to M relationship Address In a school's database system, there must be entities of students, subjects and teachers. Pupils have attributes such as name, ID number and address. Based on the given situation, construct an ERD showing the one-to-many relationship and its relationship model. Source: goo.gl/ pPKaFS http:// creately.com Figure 2.1.12 ERD shows the M to N relationship ERDs are visual tools that link relational databases and networks. Since ERD was introduced, ERD has evolved and is sometimes used for business management, product development and in formulation strategy formulation. Order No 72 Computer Science Form 5 Table 2.1.5 Relationship scheme 1 to M Did you know? You 2 One-to-many relationship like Figure 2.1.11 3 Many-to-many relationships like Figure 2.1.12 Machine Translated by Google


Student ID Item No. Item Name Students name GOODS_SUPPLIERS Supplier No RAW_MATERIAL_SUPPLIERS Class Item No Mind Test LOAN SUPPLIERS Loan No Supplier Name Supplier Name Street City Zip Code State SUPPLIERS RAW MATERIAL Borrow Date Return date Quantity Student ID The unit price STUDENTS ITEM Student ID In a many-to-many relationship, a new table needs to be formed and the primary key linking the two entities will be a foreign key in this table. For this reason, NoPembekal and NoBahan will be foreign keys in the table PEMBEKALK_BAHAN_MENTAH as in Table 2.1.6. Normalized Relationship Schema 3 Foreign key selection based on the type of relationship between entities. 1 Entities will be table names such as STUDENTS, GOODS, LOANS and SUPPLIERS. A normalized relationship schema can be generated based on the ERD sketch. 2 The attribute will be the field name as in Figure 2.1.13. Based on Figure 2.1.7 (inventory management system), map to a normalized relational scheme. Examine the following mapping steps: Address Material No Cost Supplier No "A database will be developed to store employee information in a bank. Employee personal information such as name, address and telephone number will be recorded. They are also given an employee ID. Later, they are assigned to different departments such as Human Development, Accounts, Operations and so on. In each division, there are several managers and employees. Based on the given situation, identify the available entities, attributes, relationships and cardinalities. Table 2.1.6 M to N relationship scheme Material No Supplier No CHAPTER 2 Advanced Database 73 Each bank customer will deal with a bank employee or several customers will deal with a bank employee at a time.” Figure 2.1.13 Normalized relationship schema Name TotalUnits Solution: Machine Translated by Google


Normalization aims to produce a relational schema by placing attributes into the table correctly to avoid anomaly problems. Therefore, the data obtained will be inaccurate. A data relation is in first normal form (1NF) if none of the attributes have repeating data sets. Each attribute has only one value. Example: Table 2.1.7 is in a non-normalized form because it contains repeated attributes, namely IDMurid, StudentName and Class. A table is said to be in first normal form when repeating groups of data are eliminated. This is done by forming a primary key as in Table 2.1.8. An anomaly is an error that may occur when a user wants to update a table that contains repeating data. When you want to change some data in the table, you need to make changes to some other records. Failure to do so will result in a lack of integrity in the database. Sometimes you may get information in the form of a table like in Table 2.1.7. If the information in the table is examined, it is found that there are attributes that have repeating groups of data. To produce a normalized relational schema, a normalization process needs to be performed. Normalization is the process of ensuring that the resulting logical data model has minimal anomalies. 3 Purple 09/8/2017 Item No. Item Name Item Quantity Price Unit Name Supplier ID Address Student Name Student Class Date Borrow Date Return Alor Setar Beautiful Sports Batons Netball A01 Elisa 30.50 1 Red 02/7/2017 07/7/2017 10.30 Goddess 20.00 12/8/2017 Advance Goose A03 Football, Shah Alam Kuching M2000 20 10 M1000 4 Blue Loyal Sports 15.30 Lim 5 07/7/2017 Shah Alam M3000 Loyal Sports Hockey ball A05 02/7/2017 10 goo.gl/ mZlulx Data Anomalies Table 2.1.7 Inventory Management Table in 0NF form 74 Computer Science Form 5 First Normalized Form (1NF) Normalization Machine Translated by Google


STUDENTS ITEM LOAN ITEM Did you know? You Second Normalized Form (2NF) key If there is a non-key attribute that depends on only one of the key attributes, then the relationship is said to have a partial dependency. Example: The GOODS table in Table 2.1.8 has two primary keys (known as candidate keys), namely NoBarang and IDMurid. However, the ItemName, Quantity, UnitPrice, SupplierName and Address attributes only depend on ItemNo and the StudentName and Class attributes only depend on IDMurid. Only the BorrowDate and ReturnDate attributes depend on both keys, namely ItemNo and IDMurid. The solution, we need to create a new table to represent the Borrow Date and the Return Date. •All non-key attributes are fully dependent on attributes A data relation is in second normal form if the following criteria are met: •The table is in first normal form 10.30 Alor Setar M1000 Lim Kuching M2000 Loyal Sports A01 1 Red 02/7/2017 02/7/2017 4 Blue Netball Hockey ball A05 Goddess Football 20 30.50 Loyal Sports 20.00 Lim 1 Red 02/7/2017 Elisa Shah Alam M3000 Item No. Item Name Item Quantity Price Unit Name Supplier ID Address Student Name Student Class Date Borrow Date Return 02/7/2017 5 07/7/2017 3 Purple 09/8/2017 A02 15.30 A03 10 07/7/2017 12/8/2017 Shah Alam M1000 10 Beautiful Sports Advance Goose Batons Table 2.1.9 Second normal form (2NF) GOODS table Student ID Borrow Date Table 2.1.8 First form GOODS table (1NF) Item No Return date Unit Price Supplier Name Steps to form the second normalization: Item name Student ID ÿ Check tables that have candidate keys Quantity Students name ÿ For each non-attribute key, check if the key is the first part or the second part Address Class ÿ Delete partial keys and their dependencies to form new tables CHAPTER 2 Advanced Database 75 Item No Machine Translated by Google


Transitive dependency means that there is a dependency between non-key attributes. Example: Table 2.1.9 shows the GOODS table which is in second normal form and there is a transitive dependency, that is the Address attribute depends on the SupplierName attribute and both are non-key attributes. Therefore, these two attributes need to be separated from the GOODS table. The solution to the transitive dependency problem is done by creating a new table of interdependent non-key attributes as in Table 2.1.10. •The table is in second normal form • There is no transitive dependency A relation is in third normal form if it meets the following criteria: Get basic documents such as sales slips, customer invoices and book loan slips. Based on the information contained in this document, prepare the following items: 1 List the attribute names found on each document. Generate a Normalized Relationship Schema Mind Test LOAN 2 List the functional dependencies between attributes for each document. SUPPLIERS Take a tour of one of the following environments: • Bookshop 3 Draw a relationship diagram for each document. • Supermarket ITEM • Library STUDENTS Notice how transactions occur in each environment above. ACTIVITY 2 Group work The unit price goo.gl/ g1p1GG Supplier name Students name Class Table 2.1.10 Third normal form (3NF) GOODS table Item No Supplier name State the difference between partial dependency and transitive dependency. Student ID Fifth Normal Form 76 Computer Science Form 5 Borrow Date goo.gl/ g1p1GG Third Normal Form Item No Return date Item name goo.gl/ mUVyTz The normalization form is not limited to third normalization form (3NF) only, but can include fourth and even fifth normalization forms. You can find out more by visiting goo.gl/ RfBxnm. Quantity Student ID Address Third Normal Form Did you know? Third Normalized Form (3NF) You Machine Translated by Google


•DELETE 3 Data Control Language or Data Control Language (DCL) – SQL statements that control access to data in the database 1 Data Definition Language or Data Definition Language (DDL) – SQL statements used to create and modify database structures. Example: •CREATE data. Example: • ALTER • GRANTS • DROP •REVOKE Structured Query Language or Structured Query Language, abbreviated as SQL, is used to access and update data from a database. Based on ANSI (American National Standard Institute), SQL is a standardized programming language used to connect to databases through database management systems. This standard does not depend on the type of machine used whether it is International Business Machines (IBM), Microsoft or Oracle. Because of this, almost all database management systems recognize SQL statements. 2 Data Manipulation Language or Data Processing Language (DML) – SQL statements used to manipulate data in tables. Example: •SELECT When creating a table, you need to select the data type for each column that will be formed in the table. The data type selected determines the type of data that can be stored in the field. • INSERT Choosing the right data type is important because it affects the overall performance of the database. The data type also determines the amount of storage space required. Table 2.1.11 describes the data types in My SQL. •UPDATE SQL commands are divided into three languages, namely: Introduction to SQL Did you know? You Introduction to Data Types ÿ delete records from the database and so on ÿ update records in the database Among the things that SQL can do are: CHAPTER 2 Advanced Database 77 ÿ execute queries to the database The School Management System (SPS) was built by the Malaysian Ministry of Education to manage school information and data, teachers, students, examinations and co-curriculum. ÿ trace data from database SPS aims to help reduce the workload of administrators and teachers when managing school data. ÿ enter records into the database Application Daily 2.1.3 SQL: Building a Database Machine Translated by Google


A string with a maximum length of 255 words. VARCHAR is used for columns that contain data that is not A string with a maximum length of 65,535 words. Large numbers that have a decimal point. Date with YYYY-MM-DD format. uniform Example: Name, Address Numbers in the range –2,147,483,648 to 2,147,483,647 or positive numbers 0 to 4,294,967,295. Date and time in YYYY-MM-DD/HH:MM:SS format. Description FLOAT Time in HH:MM:SS format Science Innovation DOUBLE Computer VARCHAR DATE Data Types TINYTEXT DATETIME CHAR TEXT TIME A constant string between 0 and 255 words. CHAR is used for columns that contain fixed and uniform data. Example: Gender INT A small number that has a decimal point. A string that can be changed between 0 and 255 words. Databases can be developed using Database Management Systems such as MS Access, Oracle, MySQL and so on. To develop a database using MySQL, this application can be launched through the XAMPP Control Panel window as shown in Figure 2.1.14. Did you know? You Building a Database Table 2.1.11 Types of data in My SQL This unmanned aerial vehicle system will increase the efficiency of obtaining information on the earth's surface to meet the needs of disaster monitoring, natural resource management and land clearing in addition to playing an important role in providing information to preserve national sovereignty and other public uses in this country. The name XAMPP is an abbreviation of X (that is four operating systems such as Windows, Linux, Mac OS and Solaris), Apache, MySQL, PHP and Perl. XAMPP is open source software (open source) and works as a standalone server (localhost). On 13 October 2015, the Ministry of Science, Technology and Innovation (MOSTI) through the Malaysian Remote Sensing Agency (ARSM) successfully developed two units of the Unmanned Aerial Vehicle–Remote Sensing (UAV–RS) system. 78 Computer Science Form 5 Figure 2.1.14 XAMPP Control Panel Machine Translated by Google


Figure 2.1.16 Creating a database Figure 2.1.15 phpMyAdmin CHAPTER 2 Advanced Database 79 Description: 4 2 1 3 Click on the Databases tab to create the database you want. Example: You want to create a database named storsukan. Click on the Databases tab and give the name of the database you want and click the Create button. The created database can be seen on the left side of your screen as shown in Figure 2.1.16. When the XAMPP Control Panel window is displayed, click the Start button corresponding to the Apache module and the MySQL module. Next, click the Admin button located on the MySQL module to launch phpMyAdmin as shown in Figure 2.1.15. 1 Click on the Databases tab. 3 Click the Create button. 4 The database has been successfully created. 2 Give the name of the database you want. Example: store sports. Machine Translated by Google


item VARCHAR (10) Name_field2 data type (size) NOT NULL, Field Name INT (3) Name_field3 data type (size), Item No My Malaysia! …………… Name FLOAT(5,2) VARCHAR (12) ) Quantity Description The unit price Main key Student ID Not null Example 2 shows how to create a table named item that has five fields. Suppose the item table contains the structure as in Table 2.1.12. Data Types ItemNo is the primary key for this table. The Name field is defined as NOT NULL, which means the field must have a value and cannot be left blank. To create a table in a storage database, make sure you click on storage and then click SQL to write an SQL statement. CREATE TABLE table name ( VARCHAR (6) Next, click GO to execute the SQL statement as in Figure 2.1.17. field_name1 data type (size) PRIMARY KEY, Table 2.1.12 Structure of the item table 80 Computer Science Form 5 (LCA) or Life-Cycle Under Plan Assessment that will enable Ninth Malaysia to develop a database the industry assesses the life cycle impact of production and manufacturing processes. This encourages the use of environmentally friendly technology and (2006–2010), SIRIM was given a mandate application of selfregulation. Life Cycle Assessment EXAMPLE 2 When the database is ready to be created, click on the database to create the table you want. The following are some things to consider before creating a schedule: 3 Identify the field that will be the primary key. Primary keys are used to identify records in a table. The primary key must be unique and cannot contain null values. 2 Identify the fields that will accept null values. Format: 1 Identify the data type and maximum field size for each attribute. Creating a Table (CREATE table) Machine Translated by Google


ÿ MySQL ÿ Microsoft Access Figure 2.1.17 Creating a table ÿ IBM DB2 own Between systems ÿ Sybase ALTER TABLE command database that uses language Figure 2.1.19 Structure of the goods table goo.gl/ nalyNO The SQL is: CHAPTER 2 Advanced Database 81 ÿ Microsoft SQL Server Figure 2.1.18 Table of goods ÿ Oracle Most database management systems that exist today implement the SQL language into their version Figure 2.1.18 shows the GOODS table that has been successfully created using the CREATE TABLE statement. The created table named item will be in the database store you created earlier. This view can be reached through the Structure tab. The table structure describes the data types, field widths and values that can be entered in those fields. Figure 2.1.19 shows the structure of the item table that has been created. You Did you know? Machine Translated by Google


Description: Sometimes you want to make changes to the table structure that has been created. These include adding fields, amending or changing the data type and field size and deleting unnecessary fields. Format: ALTER TABLE – is a basic command to change the table structure This can be done with the ALTER TABLE statement. A field can be added to a table by using the ADD statement. table_name – is the name of the table to be changed Format: Change options – examples: adding fields, changing data types and deleting fields. Insert/Add Field Figure 2.1.20 Adding a new field Address 82 Computer Science Form 5 EXAMPLE 3 ADD field_name data type (size); ALTER TABLE table_name (a) Adding a new field after the last field. SQL statement: Example 3 shows the SQL statement to add the address field to the item table as in Figure 2.1.20. There are two ways to add a field: change options; ALTER TABLE table_name Changing the Table Structure Machine Translated by Google


Figure 2.1.22 Adding a new field Amount Figure 2.1.23 New field Amount added Figure 2.1.21 New field Address added CHAPTER 2 Advanced Database 83 Output: Output: SQL statement: (b) Add a new field between the two fields as in Figure 2.1.22. Generally, when a new field is added, it will be added to the last field. The ADD statement will add a new field in a table as shown in Figure 2.1.21. Machine Translated by Google


SQL 84 Computer Science Form 5 •Developer.NET and Skills in SQL create the following career opportunities: • Oracle SQL developer Figure 2.1.24 Changing the field size •SQL programmer EXAMPLE 4 ALTER TABLE table_name (a) Changing the size of the Address field from 15 to 20. Refer to Figure 2.1.24 and Figure 2.1.25. Career Science CHANGE field name new field name new data type (new size); SQL statement: Computer ALTER TABLE table_name MODIFY new datatype fieldname (newsize); Example 4 shows the SQL statement to change the field structure. The AFTER statement should be used to add a new field between two existing fields. The Amount field is added between the Quantity and Unit Price fields as shown in Figure 2.1.23. Amend/Change Fields An existing field can be amended or changed. To change the data type or data size, you can use the MODIFY statement while to change the field name, you need to use the CHANGE statement. Or Format: Format: Machine Translated by Google


Output: Output: Figure 2.1.27 Item Name field and field size changed CHAPTER 2 Advanced Database 85 Figure 2.1.25 Address field size changed Figure 2.1.26 Changing the field name (b) Change the Name field to NameItem and data type VARCHAR with size 20. Refer to Figure 2.1.26 and Figure 2.1.27. SQL statement: Machine Translated by Google


Output: Fields that have been created can be deleted by using the DROP statement. Format: Figure 2.1.28 Deleting a field 86 Computer Science Form 5 Figure 2.1.29 Amount field deleted Clear Fields Example 5 shows how to delete a field. You can delete one field or more than one field with one statement. ALTER TABLE table_name (a) Eliminate the AMOUNT field from the item table. Refer to Figure 2.1.28 and Figure 2.1.29. SQL statement: DROP field name; EXAMPLE 5 Machine Translated by Google


Figure 2.1.30 Deleting two fields Figure 2.1.31 IDMurid and Address fields are deleted CHAPTER 2 Advanced Database 87 Unnecessary tables can be deleted by using the DROP TABLE statement. Format: SQL statement: DROP TABLE table name (b) Eliminate the IDMurid and Address fields. Refer to Figure 2.1.30 and Figure 2.1.31. Output: Delete Schedule Machine Translated by Google


ACTIVITY 3 Let's say you and some group members have visited a hotel near where you live. You have interviewed the hotel official regarding the Room Reservation System. Based on the interview, you and the group members have identified the data required for the room reservation process. Following the discussion of you and the members, the following tables have been identified. 2 Add a field to record the vehicle's license plate number in the guest table. Example 6 shows how to delete an item table. Refer to Figure 2.1.32 and Figure 2.1.33. 3 Delete the occupation field from the guest table. Creating and Modifying Table Structures Based on the given table information, write SQL statements for the purposes below: 1 Create the room, reservation and guest table structure. SQL statement: Group work EXAMPLE 6 (Guest No., Check-In Date, Check-Out Date, Room No.) (Guest No., Name, Address, Occupation) •ROOM 88 Computer Science Form 5 Figure 2.1.32 Deleting the Goods table (Room No., Type, Price) •RESERVATION •GUESTS Figure 2.1.33 List of deleted items Output: Machine Translated by Google


Insert/Add (MDEC) has been mandated to CHAPTER 2 Advanced Database 89 In 2011, drive the country's transition towards digital economic development to achieve the 2020 vision, through the Digital Malaysia initiative by the Prime Minister Digital Malaysia Malaysia. Digital Malaysia was officially launched in 2012 as a national transformation program to achieve this goal. Economy Corporation Figure 2.1.34 One record is inserted into all fields EXAMPLE 7 2.1.4 SQL: Manipulating Data VALUES (value1, value2, ………….valueN); Example 7 shows how to insert data into the items table. Let's say you have an item table consisting of the fields ItemNo, ItemName, Quantity, UnitPrice and IDMurid. Insertion of records can be done by entering data into all fields or specific fields only. (a) Inserts one record into all fields in the item table. My Malaysia! INSERT INTO table_name (field1, field2, …… fieldN) SQL statement: The INSERT INTO statement is used to insert data into a table in the following format. Data Manipulation Language or Data Processing Language (DML) works to manipulate data in the database. Once the table structure is created, you can enter data into the table. In addition, you can also delete and modify the data that has been entered. Format: Machine Translated by Google


Output: Figure 2.1.36 A record is inserted into a specific field Figure 2.1.35 A record is inserted 90 Computer Science Form 5 Application for admission to the university can be done online. Prospective students can fill in the form online using applications developed by the government and also private bodies. Daily The statement in Figure 2.1.34 will add new item data into all the fields in the table. The data added must follow the order of the fields in the table, starting with Item No, Item Name, Quantity, Unit Price and IDMurid. Every data that is defined as a string such as char, varchar and date needs to be inserted using the sign ('). The output to this statement is shown in Figure 2.1.35. SQL statement: Application (b) Inserting a record in a specific field only. Machine Translated by Google


EXAMPLE 8 Figure 2.1.37 A record is inserted Figure 2.1.38 Records in the item table CHAPTER 2 Advanced Database 91 Format: The DELETE statement is used to delete data in a table. To delete a specific record, the WHERE statement needs to be used. Output: If the insertion is done for certain fields only, you need to declare the names of the fields to which you want to add records. The statement in Figure 2.1.36 shows data insertion on the Item No, Item Name and Quantity fields only. Therefore, fields with no data will receive a null value as shown in Figure 2.1.37. Example 8 shows how to delete a record in a table. There are two ways, that is to delete specific records only or to delete all records in the table. Suppose there are four records in the GOODS table as in Figure 2.1.38. WHERE field_name = value; DELETE FROM table_name DELETE Machine Translated by Google


92 Computer Science Form 5 Figure 2.1.39 Erasing hockey ball records Figure 2.1.40 Hockey ball record deleted SQL statement: The DELETE statement in Figure 2.1.39 will delete only certain records based on the conditions specified in WHERE. This statement will delete the hockey ball record only as shown in Figure 2.1.40. (a) Delete the hockey ball record in the GOODS table. Output: Machine Translated by Google


Click to View FlipBook Version