当前位置:网站首页>[path of system analyst] Chapter 15 double disk database system (relational database application)

[path of system analyst] Chapter 15 double disk database system (relational database application)

2022-06-09 07:03:00 A volley of attack

【 The path of System Analyst 】 Chapter 15 Double disk database system ( Relational database application )

Preface Analysis of real test sites over the years

1) Test point analysis

The database is examined in the morning comprehensive knowledge 5-7 branch , Generally speaking, there are 3-4 The point is to test the actual use of the database . The main test method is to give you a scene , What is your current paradigm , How to modify ; Is it damaged or not damaged at present , Whether functional dependencies are maintained after decomposition ; Or relational algebraic expressions A With which relational algebra expression is equivalent, and so on .

2) Important knowledge points

1. Relational database paradigm
2. Key of relational database
3. The meaning of some common symbols in relational algebra
4. Relational algebraic expressions are converted to equivalent SQL sentence
5. Lossless and lossy connections
6. Whether to maintain functional dependency

The first part Comprehensive knowledge over the years

2007 Next, the real problem of comprehensive knowledge over the years (3 branch )

【2007 The second part is the true question 31 topic : green 】
31. Establish a supplier 、 Part database . among “ supplier ” surface S(Sno,Sname,Zip,City) The attributes in represent : Supplier code 、 Supplier name 、 Supplier zip code 、 The supplier's city , Its functional dependency is :Sno→(Sname,Zip,City),Zip→City.“ Spare parts ” surface P(Pno,Pname,Color,Weight,City), Indicates the part number 、 Part name 、 Color 、 Weight and origin . surface S And watch P The relationship between SP(Sno,Pno,Price,Qty) Indicates the supplier code 、 Part number 、 Price 、 Number .
a.“ supplier ” surface S Belong to (42).
b. If required : Supplier code cannot be empty , And the value is unique , The name of the supplier is also unique ; The part number cannot be empty , And the value is unique ; One supplier can supply multiple parts , A part can be supplied by multiple suppliers . Please put the following SQL Complete the blank part of the sentence .
CREATE TABLE S(Sno CHAR(5)(43),
Sname CHAR(30) UNIQUE,
Zip CHAR(8),
City CHAR(20) (44)
);
(42)
A.1NF
B.2NF
C.3NF
D.BCNF
(43)
A.FOREIGN KEY
B.NOT NULL UNIQUE
C.FOREIGN KEY(Sno)
D.PRIMARY KEY(Sname)
(44)
A.NOT NULL
B.NOT NULL UNIQUE
C.PRIMARY KEY(Sno)
D.PRIMARY KEY(Sname)

answer : The answer is B|B|C.
test questions (43) The right answer is B, Because the test questions require that the supplier code cannot be empty , And the value is unique , The name of the supplier is also unique , So we need to use NOT NULL UNIQUE.
test questions (44) The right answer is C, Because of the watch S Is the primary key Sno, So we need to use PRIMARY KEY(Sno) To restrain .

2008 Comprehensive knowledge over the years (3 branch )

【2008 The first part of the year is the truth problem 36 topic : green 】
36. The Department of a company ( Department number , Department name , person in charge , Telephone )、 goods ( Commodity number , Name of commodity , The unit price , Inventory ) And staff ( Employee number , full name , address ) The relationship between the three entities is shown in the table 1、 surface 2 And table 3 Shown . Suppose each department has a person in charge and a telephone , But there are several employees ; Each product can only be sold by one department .
 Insert picture description here
The reason why Department relations do not belong to the third paradigm is (40). If the user asks for a table 4 The results shown , need (41), And add a relationship pattern (42).
(40)
A. It does not eliminate the partial functional dependence of non primary attributes on codes , Such as : Department name → person in charge
B. It does not eliminate the partial functional dependence of non primary attributes on codes , Such as : person in charge → Telephone
C. It only eliminates the partial functional dependence of non primary attributes on codes , Without eliminating the transfer function dependency
D. There is no elimination of partial functional dependence and transfer functional dependence of non primary attributes on codes
(41)
A. Modify table 1 Structure , In the table 1 Add an employee ID in the
B. Modify table 2 Structure , In the table 2 Add an employee ID in the
C. Modify table 2 Structure , In the table 2 Add a department number in
D. Modify table 3 Structure , In the table 3 Add a department number in
(42)
A. sales ( Employee number , Commodity number , date , Number )
B. sales ( Employee number , Name of commodity , Commodity number , Number )
C. sales ( Employee number , Department number , date , Number )
D. sales ( Employee number , Department number , Commodity number , date )

answer : The answer is C|D|A. This question examines the candidate's response to the paradigm 、SQL Mastery of language .

2008 Next, the real problem of comprehensive knowledge over the years (3 branch )

【2008 The second year of the year is the true question 32 topic : green 】
32. Some relational models of the database of a company's online sales management system are as follows . among , The customer number uniquely identifies a customer , The product number uniquely identifies a product , The order number uniquely identifies an order . An order must correspond to only one customer , An order can consist of one or more order details , A customer can have multiple orders .
Customer ( Customer number , full name , Gender , Address , Zip code )
product ( Product number , name , stock , The unit price )
Order ( The order number , Time , amount of money , Customer number )
The order details ( The order number , Product number , Number )
The primary key of the order relation mode is (40); The primary key of the order details relation mode is (41); The foreign key of the order is (42).
(40)
A. The order number
B. Customer number
C.( The order number , Customer number )
D.( The order number , Time )
(41)
A. The order number
B. Product number
C.( The order number , Product number )
D.( The order number , Number )
(42)
A. Customer number , The foreign key of order details is order No
B. Customer number , The foreign keys of order details are order number and product number
C. The order number , The foreign key of the order details is the product number
D. The order number , The foreign keys of order details are order number and product number

answer : The answer is A|C|B. This question examines the candidate's mastery of the basic concepts of relational databases . Biweekly eyes yellow to green ,

  1. The order number uniquely identifies an order , The primary key of the order relation mode is the order number .
  2. Because an order can consist of one or more order details , The order details indicate the product number and quantity , Therefore, the primary key of the order details relationship mode is “ The order number , Product number ”.
  3. Because the primary key of the customer relationship mode is the customer number , So the foreign key of the order is “ Customer number ”; and “ The order number ” and “ Product number ” They are the primary keys of orders and products , Therefore, the foreign key of the order details is “ The order number , Product number ”.

2009 Comprehensive knowledge over the years (4 branch )

【2009 The year is a true topic 34 topic : green 】
34. Goods of a company ( Commodity number , Name of commodity , manufacturer , The unit price ) And the warehouse ( Warehouse number , Address , Telephone , Commodity number , Inventory ) The relationship between two entities is shown in table 1 And table 2 Shown .
 Insert picture description here
The primary key of the commodity relationship is (42); The primary key of the warehouse relationship is (43); Warehouse relations (44), To solve this problem , The warehouse relationship needs to be broken down into (45).
(42)
A. Commodity number
B. Name of commodity
C. manufacturer
D. The unit price
(43)
A. Warehouse number , Address
B. Warehouse number , Telephone
C. Warehouse number , Commodity number
D. Address , Telephone
(44)
A. No redundancy 、 No insertion exception , But there is a deletion exception
B. No redundancy , But there are insert and delete exceptions
C. Redundancy exists , But there is no inconsistency in the modification operation
D. Redundancy exists 、 Inconsistencies in modification operations , And insert and delete exceptions
(45)
A. Warehouse 1( Warehouse number , Address ) And the warehouse 2( Warehouse number , Telephone , Commodity number , Inventory )
B. Warehouse 1( Warehouse number , Address , Telephone ) And the warehouse 2( Commodity number , Inventory )
C. Warehouse 1( Warehouse number , Telephone ) And the warehouse 2( Warehouse number , Address , Commodity number , Inventory )
D. Warehouse 1( Warehouse number , Address , Telephone ) And the warehouse 2( Warehouse number , Commodity number , Inventory )

answer : The answer is A|C|D|D. This question examines the candidate's response to the primary key in the relational model 、 Foreign keys and schema decomposition and related knowledge . Send questions .

2010 Comprehensive knowledge over the years (3 branch )

【2010 It's true question no 32 topic : yellow 】
32. Part relationship of a sales company database ( Part number , Part name , supplier , The location of the supplier , Inventory ) As shown in the following table , The same part can be supplied by different suppliers , One supplier can supply multiple parts . The primary key of the part relationship is (43), There are some problems in this relationship, such as redundancy, insertion exception and deletion exception . In order to solve this problem, we need to decompose the part relationship into (44), The decomposed relational pattern can achieve (45).
 Insert picture description here
(43)
A. Part number , Part name
B. Part number , supplier
C. Part number , The location of the supplier
D. supplier , The location of the supplier
(44)
A. Spare parts 1( Part number , Part name , supplier , The location of the supplier , Inventory )
B. Spare parts 1( Part number , Part name )、 Spare parts 2( supplier , The location of the supplier , Inventory )
C. Spare parts 1( Part number , Part name )、 Spare parts 2( Part number , supplier , Inventory )、 Spare parts 3( supplier , The location of the supplier )
D. Spare parts 1( Part number , Part name )、 Spare parts 2( Part number , Inventory )、 Spare parts 3( supplier , The location of the supplier )、 Spare parts 4( The location of the supplier , Inventory )
(45)
A.INF
B.2NF
C.3NF
D.4NF

answer : The answer is B|C|C. The last mistake , Two week eyes are still yellow .

  1. The original part relationship has partial functional dependence of non primary attribute on code :( Part number , supplier )― The location of the supplier , But the supplier ― The location of the supplier , Therefore, the original relationship model parts are not 2NF Of .
  2. Exploded relational schema part 1、 Spare parts 2 And parts 3 The partial functional dependence of non primary attributes on codes is eliminated , At the same time, there is no transitive dependency , Therefore, to achieve 3NF

2011 Comprehensive knowledge over the years (5 branch )

【2011 The year is a true topic 34 topic : green 】
34. Given the relational schema R(U, F), among , Property set t/={ City , The street , Postal Code }, Functional dependency set F={ City , The street )→ Postal Code , Postal Code → City }. Relationship R(41), And there are (42).
(41)
A. Only 1 Candidate keywords “ City , The street ”
B. Only 1 Candidate keywords “ The street , Postal Code ”
C. Yes 2 Candidate keywords “ City , The street ” and “ The street , Postal Code ”
D. Yes 2 Candidate keywords “ City , The street ” and “ City , Postal Code ”
(42)
A.1 Two non primary properties and 2 There are two main attributes
B.0 Two non primary properties and 3 There are two main attributes
C.2 Two non primary properties and 1 There are two main attributes
D.3 Two non primary properties and 0 There are two main attributes

answer : The answer is C|B. Biweekly eyes yellow to green . More classic test method . Focus on .
test questions (41) The correct answer is C. Because according to the definition of functional dependency , Can be launched ( City , The street )→U,( Postal Code , The street )→U, therefore “ City , The street ” and “ The street , Postal Code ” For candidate keywords .
test questions (42) The correct answer is B. Because according to the definition of the main attribute ,“ The attribute contained in any candidate code is called the primary attribute (Prime attribute), Otherwise, it is called non primary property (Nonprime attribute)”, So... In the relationship 3 Each attribute is a primary attribute , Instead of the main attribute .

【2011 The year is a true topic 35 topic : green 】
35. There are employee entities Employee ( Employee number , full name , Gender , Age , Telephone , Home address , Members of the family , Relationship , contact number ). among ,“ Home address ” Including the zip code 、 province 、 City 、 Street information ;“ Members of the family , There are multiple family members . Employee entity Employee The primary key of is (43); The relationship belongs to (44); To make the database schema design more reasonable , For the employee relationship model Employee(45).
(43)
A. Employee number
B. Employee number , Members of the family
C. full name
D. full name , Members of the family
(44)
A.2NF, No redundancy , No insert exception and delete exception
B.2NF, No redundancy , But there are insert exceptions and delete exceptions
C.1NF, Redundancy exists , But there is no inconsistency in the modification operation
D.1NF, There are inconsistencies between redundancies and modification operations , And insert and delete exceptions
(45)
A. Only one relative's name is allowed to be recorded 、 The relationship with employees and the contact number
B. You can do nothing , Because the relationship pattern achieves 3NF
C. Add more family members 、 Relationship and contact number fields
D. Family members should be 、 Relationship and contact number plus employee number as an independent model

answer : The answer is B|D|D. Biweekly eyes yellow to green .

  1. test questions (43). Because an employee can have multiple family members , So in order to distinguish Employee Every tuple in a relationship , Its primary key is ( Employee number , Members of the family ).
  2. test questions (44). Relationship model Employee yes 1NF, The reason is that employee number one ( full name , Gender , Age , Telephone , Home address ), That is, non primary attribute ( full name , Gender , Age , Telephone , Home address ) Not entirely dependent on the code “ Employee number , Members of the family ”, so Employee Do not belong to 2NF.1NF There is 4 A question : It's redundant 、 Causes inconsistencies in modification operations 、 Insert and delete exceptions .
  3. test questions (45). If an employee has 5 A relative , Then in the employee relationship “ Employee number , full name , Gender , Age , Telephone , Home address ” Will repeat 5 Time , In order to design the database schema more reasonably , Redundancy should be eliminated , About family members 、 Relationship and contact number plus employee number are designed to become an independent model

2012 Comprehensive knowledge over the years (6 branch )

【2012 The year is a true topic 30 topic : green 】
30. A company sells goods in the database 、 Warehouse relation pattern and functional dependency set Fl、F2 as follows : goods ( Commodity number , Name of commodity , manufacturer , The unit price ),Fl={ Commodity number → Name of commodity , Commodity number → manufacturer , Commodity number → The unit price )}, The primary key of the commodity relationship is (40). Warehouse ( Warehouse number , Address , Telephone , Commodity number , Inventory ),F2={ Warehouse number →( Address , Telephone ),( Warehouse number , Commodity number )→ Inventory }. The primary key of the warehouse relationship is (41), The foreign key is (42). Warehouse relationship model (43), To solve this problem , The warehouse relationship needs to be broken down into (44)
(40)
A. Commodity number
B. Commodity number , Name of commodity
C. Commodity number , manufacturer
D. Name of commodity , manufacturer
(41)
A. Warehouse number
B. Warehouse number , Commodity number
C. Warehouse number , Telephone
D. Address , Telephone
(42)
A. Warehouse number
B. Address
C. Telephone
D. Commodity number
(43)
A. Redundancy exists 、 Insert and delete exceptions , And inconsistencies in modification operations
B. There is no redundancy , But there are insert and delete exceptions
C. There is no inconsistency in the modification operation , But there are redundancy and insertion exceptions
D. There is no redundancy 、 Insertion exception , However, there are inconsistencies between deletion exceptions and modification operations
(44)
A. Warehouse 1 ( Warehouse number , Address ) And the warehouse 2 ( Warehouse number , Telephone , Commodity number , Inventory )
B. Warehouse 1 ( Warehouse number , Address , Telephone ) And the warehouse 2 ( Commodity number , Inventory )
C. Warehouse 1( Warehouse number , Telephone ) And the warehouse 2 ( Warehouse number , Address , Commodity number , Inventory )
D. Warehouse 1 ( Warehouse number , Address , Telephone ) And the warehouse 2 ( Warehouse number , Commodity number , Inventory )

answer : The answer is A|B|D|A|D.
There is redundancy in the warehouse relationship 、 Insert and delete exceptions , And inconsistencies in modification operations . for example , Warehouse number by “12” There are three kinds of goods , The address has to be repeated three times ,

【2012 The year is a true topic 31 topic : green 】
31. If the relationship R (A, B, C, D)、S (C, D,E) Conduct π1,2,3,4,7(σ3=5^4=6(R*S)) operation , Then the algebraic expression of the relationship is the same as (45) It is equivalent. .
A. Insert picture description here
B. Insert picture description here
C. Insert picture description here
D. Insert picture description here

answer : The answer is A. Send questions .

  1. Natural connection is a special equivalent connection , It requires two relations are compared must be the same component attribute group , And remove the duplicate attribute columns from the result set .
  2. This question σ3=5^4=6(RS) The meaning is RS after , selection R and S In relationship R.C = S.C^R.D = S.D tuples , Proceed again R.A、R.B、R.C、R.D and S.E Projection relation operation of . so , The operation expression of this relationship is the same as R*S It is equivalent. .

2013 Comprehensive knowledge over the years (3 branch )

【2013 The year is a true topic 33 topic : green 】
33. Given a relational schema K ( Department number , Department name , person in charge , Department phone )、 Doctor Y ( Doctor number , Doctor's name , Gender , Department number , contact number , Home address ) And the patient B ( Medical record No , Patient name , Gender , Medical insurance No , Contact information ), also 1 There are many doctors in each department ,1 A doctor belongs to 1 Departments ;1 A doctor can treat multiple patients ,1 A patient can also find more than one doctor .
Between the Department and the doctor “ Belongs to ” Contact type 、 Between doctors and patients “ Diagnosis and treatment ” The contact types are
(43); among (44). Inquire about “ Hepatobiliary ” The doctor's name 、 In the relational algebraic expression of contact number and home address , The most efficient query is (45).
(43)
A.1:1、n:m
B.n:m、1:1
C.n:m、1:n
D.l:n、n:m
(44)
A.“ Diagnosis and treatment ” The connection needs to be transformed into an independent relationship , And take the doctor number and patient name as the primary key
B.“ Diagnosis and treatment ” The connection needs to be transformed into an independent relationship , And take the doctor number and medical record number as the primary key
C.“ Belongs to ” The connection needs to be transformed into an independent relationship , And take the doctor number and department name as the primary key
D.“ Belongs to ” The connection needs to be transformed into an independent relationship , And take the doctor number and department number as the primary key
(45)
A. Insert picture description here
B. Insert picture description here
C. Insert picture description here
D. Insert picture description here

answer : The answer is D|B|D. The second, the third, the second and the second week are still wrong . Three round eyes are green .

  1. There are more than one doctor in a department , A doctor belongs to a department , So between the Department and the doctor “ Belongs to ” The contact type is l:n
  2. Because one doctor can treat multiple patients , A patient can also see more than one doctor , So between doctors and patients “ Diagnosis and treatment ” The contact type is n:m.
  3. Between doctors and patients “ Diagnosis and treatment ” The contact type is n:m when , It needs to be transformed into an independent relationship , And take the doctor number and medical record number as the primary key .
  4. According to the criteria of query optimization of relational algebraic expressions 1 “ Perform the selection operation ahead of time ”, That is, for the expression with selective operation , It should be optimized into an equivalent expression that performs the selection operation as early as possible , To get smaller intermediate results , Reduce the amount of computation and the number of reads from external memory . Rules 2“ Combining the product and the selection operation after it is the join operation ”, That is, in the expression , When the product operation is followed by the selection operation , Should be merged into join operations , Make the selection complete with the product , To avoid after the product , It is necessary to scan a large product relationship for selection operation

2014 Comprehensive knowledge over the years (4 branch )

【2014 The year is a true topic 32 topic : green 】
32. Given the relational schema R(U,F),U={A,B,C,D},F={AB→C,CD→B}. Relationship R(42), And there are (43).
(42)
A. Only 1 Candidate keywords ACB
B. Only 1 Candidate keywords BCD
C. Yes 2 Candidate keywords ACD and ABD
D. Yes 2 Candidate keywords ACB and BCD
(43)
A.0 Two non primary properties and 4 There are two main attributes
B.1 Two non primary properties and 3 There are two main attributes
C.2 Two non primary properties and 2 There are two main attributes
D.3 Two non primary properties and 1 There are two main attributes

answer : The answer is C|A. This paper examines the basic knowledge of relational database normalization theory .

  1. First A and D Only out but not in , It must be one of the keywords ,ABD Can be launched C, therefore ABD Is a candidate keyword ,ACD You can also calculate B, that ACD It's also a candidate key .
  2. The attribute constituting the candidate keyword is the primary attribute ,ABCD All have candidate keys , Then there should be 4 There are two main attributes .
  3. According to the definition of functional dependency , You know ACD→U ,ABD→U, therefore ACD and ABD All are candidate keywords .
  4. According to the definition of the main attribute “ The attribute contained in any candidate code is called the primary attribute (Prime attribute), Otherwise, it is called non primary property (Nonprime attribute)”, therefore , Relationship R Medium 4 Each attribute is a primary attribute

【2014 The year is a true topic 33 topic : green 】
33. The relational parts in the sales company database are P(Pno,Pname,Sname,City,Qty),Pno Indicates the part number ,Pname Indicates the part name ,Sname Indicates the supplier ,City Indicates the location ,Qty Indicates the inventory . Its functional dependency set F={Pno→Pname,(Pno,Sname)→Qty,Sname→City}. Relationship P by (44), Large redundancy exists 、 The modification operation is inconsistent 、 The problem of inserting and deleting exceptions . If the P Decompose into (45), Can solve this problem .
(44)
A.1NF B.2NF C.3NF D.4NF
(45)
A.P1(Pname,Qty)、P2(Pno,Sname,City)
B.P1(Pname,Pname)、P2(Sname,City,Qty)
C.P1(Pno,Pname)、P2(Pno,Sname,Qty)、P3(Sname,City)
D.P1(Pno,Pname)、P2(Pno,Qty)、P3(Sname,City)、P4(City,Qty)

answer : The answer is A|C.

  1. Original part relationship P There is a partial functional dependence of non principal attributes on codes :(Pno, Sname) ——>Qty, however Pno ——>Pname、Sname ——>City, therefore P∈1NF, Instead of 2NF Of .
  2. 1NF The main problem is that the redundancy becomes larger 、 Inconsistencies in modification operations 、 The problem of inserting and deleting exceptions .
  3. The decomposed relationship pattern P1P2 and P3 The partial functional dependence of non primary attributes on codes is eliminated , At the same time, there is no transitive dependency , Therefore, to achieve 3NF.

2015 Comprehensive knowledge over the years (4 branch )

【2015 The year is a true topic 36 topic : green 】
36. Given the relational schema R(A1,A2,A3,A4),R Function dependency set on F={A1A3→A2,A2→A3}, be R(42). If the R Decompose into p={(A1A2),(A1,A3)}, Then the decomposition (43).
(42)
A. There is a candidate keyword A1A3
B. There is a candidate keyword A1A2A3
C. There are two candidate keywords A1A3A4 and A1A2A4
D. There are three candidate keywords A1A2、A1A3 and A1A4
(43)
A. It's lossless
B. Is to keep functional dependencies
C. Both lossless joins and functional dependencies
D. Both lossy joins and functional dependencies are not maintained

answer : The answer is C|D. This paper examines the basic knowledge of relational database normalization theory .

  1. test questions (42) The correct answer is C, test questions (43) The correct answer is D. because A1A3→A2,A2→A3, There was no A4, So the candidate keywords must include A4, attribute A1A3A4 Determine all attributes , Therefore, it is a candidate keyword . Empathy A1A2A4 Also for candidate keywords .
  2. set up U1={A1,A2},U2={A1,A3}, Then it can be concluded that :U1∩U2→(U1-U2)=A1→A2,U1∩U2→(U2-U1)=A1→A3, and A1-A2,A1-A3∉F+, So break down ρ It's damaging the connection . Again because F1=F2=∅, F+≠(F1∪F2)+, So decomposition does not maintain functional dependencies .

【2015 The year is a true topic 37 topic : Red 】
37. Relationship R、S As shown in the following table ,R÷(πA1A2(σ 1<3(S))) As the result of the (44),R、S Left outer connection of 、 The tuples of right outer join and complete outer join are (45).
 Insert picture description here
(44)
A.{4}
B.{3,4}
C.{3,4,7}
D.{(1,2),(2,1),(3,4),(4,7)}
(45)
A.2,2,4
B.2,2,6
C.4,4,4
D.4,4,6

answer : The answer is A|D. The second week's eyes are still red .
【 One 】
(44) Because the division operation of relational algebra is carried out from the horizontal and vertical directions of the relationship at the same time . If a given relationship R(X,Y) and S(Y,Z),X、Y、Z Attribute group ,R÷S The tuple should be in X The component value on x A collection of images Yx contain S stay Y The set of projections above . Write it down as :
 Insert picture description here among Yx by x stay R Image set ,x=tr[X]. And R÷S The attribute group of the result set of is X. According to the definition of division ,X The attribute is A3,Y The attribute is (A1,A2),R÷S The tuple should be in X The component value on x A collection of images Yx contain S stay Y The set of projections above , So the attribute of the result set is A3. attribute A3 Can take 3 It's worth {3,4,7}, among :3 The set of images is {(1,2)},4 The set of images is {(2,1),(3,4)},7 The set of images is {(4,6)}.
According to the definition of division , This question is related to S by (πA1A2(σ 1<3(S)), In the attribute group Y(A1A2) The projection on is {(2,1),(3,4)} The following table
 Insert picture description here
As can be seen from the above analysis , Only relationship R Properties of A3 The value of is 4 when , Its image set contains relationships S In the attribute group X namely (A1,A2)] The projection on the , therefore R÷S={4}.
(45) Two relationships R and S When making a natural connection , Select two relationships R and S Equal tuples on public attributes , Remove the duplicate attribute columns to form a new relationship . under these circumstances , Relationship R Some tuples in may be in the relationship S There are no equal tuples on public attribute values in , Create a relationship R The values of these tuples are discarded in the operation ; The same relationship S Some tuples in may also be discarded . So , The left outer join of relational operation is extended 、 Right outer connection and complete outer connection .
Left outer connection refers to R And S When making a natural connection , Only A Put the discarded tuples in the new relationship .
The right outer connection refers to R And S When making a natural connection , Only S Put the discarded tuples in the new relationship .
Complete outer connection means R And S When making a natural connection , Put the ruler and ^ The tuples discarded in are put into the new relationship .
test questions (45)R And S Left outer connection of 、 The results of right outer connection and complete outer connection are shown in the following table :
From the result of the operation, we can see R And S Left outer connection of 、 The tuples of right outer join and complete outer join are 4,4,6.
【 Two 】
The first thing to ask for is R÷(πA1,A2(σ1<3(S))) Result , We will first (πA1,A2(σ1<3(S))) The result of , by :
Then determine which attributes are included in the division result set . This property is : The attribute set of the divided relation - From the property set of divisor relation , Here it is R(A1,A2,A3)-(A1,A2)=A3, So the result set should be single attribute , From here we can already rule out D Options. .
Next, the result set requirements and divisor records “2,1” and “3,4” The records spliced together are in the original relationship R You can find it all in the library . Meeting this condition , Only {4}.
An extranet can be a left out join 、 Right outer join or full outer join .
stay FROM Clause , Can be specified by one of the following groups of keywords :
1)LEFT JOIN or LEFT OUTER JOIN
The result set of the left out join includes LEFT OUTER All rows of the left table specified in Clause , Not just the rows that the join columns match . If a row in the left table does not match a row in the right table , All selection list columns in the right table in the associated result set row are null .
2)RIGHT JOIN or RIGHT OUTER JOIN
The right outer join is the reverse join of the left outer join . All rows of the right table will be returned . If a row in the right table does not match a row in the left table , Null value will be returned for the left table . 3)FULL JOIN or FULL OUTER JOIN
A full outer join returns all rows in the left and right tables . When a row has no matching row in another table , The selection list column of another table contains null values . If there are matching rows between tables , The entire result set row contains the data values of the base table .
In the subject , On the left is R, On the right is S, Their records are 4, Therefore, the number of records of both left and right external connections is 4, When fully connected , The records in the left table and the right table will be listed , But both the left table and the right table have A1 And A2 by “2,1” and “3,4” So there will be 6 Bar record .

2016 Comprehensive knowledge over the years (4 branch )

【2016 The year is a true topic 30 topic : green 】
30. Given the relationship R(A,B,C,D) And relationship S(C,D,E), Do the natural join operation on it R ⋈ S The properties after are listed as (44) individual ; And σR.B>S.E(R ⋈ S) The equivalent relational algebraic expression is (45).
(44)
A.4 B.5 C.6 D.7
(45)
A.σ2>7(R×S)
B.π1,2,3,4,7(σ´2´>´7Λ3=5Λ4=6(R×S))
C.σ’2’>’7’(R×S)
D.π1,2,3,4,7(σ2>7Λ3=5Λ4=6(R×S))

answer : The answer is B|D.

  1. Yes R And S When doing natural join operations , The connection condition is :R.C=S.C and R.D=S.D. The operation result will automatically repeat the column , So the results are listed as :A、B、C、D、E, altogether 5 Column .

【2016 The year is a true topic 29 topic : yellow 】
29. Hypothetical relationship R(A1,A2,A3) The one on is decomposed into ρ={(A1,A2),(A1,A3)}, The following table shows the relationship R Last instance , According to the example R The set of functional dependencies for F by (42), decompose p(43).
 Insert picture description here (42)
A.F={A1→A2}
B.F={A1A3→A2,A1A2→A3}
C.F={A1→A3}
D.F={A1→A2,A1→A3}
(43)
A. It's lossless
B. Is to keep functional dependencies
C. It's damaging
D. Unable to determine whether to maintain functional dependency

answer : The answer is B|C. The first air-to-air pair of two weeks' eyes , So red turns yellow .

  1. because A1 by a when ,A2 May be a or b or c, So you can be sure A1→A2 Don't set up . Empathy A1→A3 Don't set up . be ACD All three options can exclude .
  2. (A1A2)∩(A1A3)=A1
  3. (A1A2)-(A1A3)=A2
  4. (A1A3)-(A1A2)=A3
  5. because A1→A2 And A1→A3 None of them , So it's detrimental to .

2017 Comprehensive knowledge over the years (5 branch )

【2017 The year is a true topic 32 topic : green 】
32. There are employee relations Emp ( Employee number , full name , Gender , Age , Telephone , Home address , Members of the family , Relationship , contact number 〉. among ,“ Members of the family , Relationship , contact number ” The names of the employees' relatives were recorded respectively 、
The relationship with employees and the contact number , And an employee is allowed to have multiple family members . To make the database schema design more reasonable , about Employee relations Emp(41).
(41)
A. Only one relative's name is allowed to be recorded 、 The relationship with employees and the contact number
B. You can do nothing , Because the relationship pattern achieves 3NF
C. Add more family members 、 Relationship and contact number fields
D. Family members should be 、 Relationship and contact number plus employee number are designed into an independent model

answer : The answer is D. Send questions .

  1. In the title, employees are allowed to have multiple family members , At this time, if you want to record multiple family members , It will inevitably lead to the redundancy of data in the table .
  2. At this time, it is the most ideal state to split the table .

【2017 The year is a true topic 33 topic : yellow 】
33. Given the relational schema R < U ,F >, U= {A,B,C,D ,E} , F = {B→A ,D→A ,A→E ,AC→B }, be R The candidate keywords for are (42), decompose ρ= {Rl(ABCE),R2(CD)} ( 43).
(42)
A. CD
B. ABD
C. ACD
D.ADE
(43)
A. With lossless connectivity , And keep the function dependent
B. No lossless connectivity , But keep functional dependencies
C. With lossless connectivity , But don't keep functional dependencies
D. No lossless connectivity , And don't keep functional dependencies

answer : The answer is A|D. Two week yellow eyes . According to the meaning of the question, we can draw the function dependence diagram :

 Insert picture description here
The picture shows , The degree of 0 Only C And D, And the combination of the two can traverse the whole graph , therefore CD Candidate key

【2017 The year is a true topic 34 topic : green 】
34. stay Turn off system R(A1 , A2 , A3) and S(A2 , A3 , A4 ) on  Insert picture description here
Relationship between operation , Equivalent to the relational expression is (44).
(44)
A. Insert picture description here
B. Insert picture description here
C. Insert picture description here
D. Insert picture description here

answer : The answer is D.

  1. A Relational algebraic expression of options , The mistake is that the two conditions chosen should not be “ or ” Relationship .
  2. B Relational algebraic expression of options , The mistake is R And S Only the operation of Cartesian product , The same attributes are not listed for equivalence judgment . Should be added :2=4 And 3=5 The choice conditions are right .
  3. C Relational algebraic expression of options , And B Option has the same error , At the same time, the projection column number is not correct .
  4. The back is empty , The first thing worth noting is , There is a common error in the options , namely “S.A4<’95’” It should be revised to “S.A4=’95’”.
  5. Several conditions in the options are correct , You need to choose , In fact, it's just using AND still OR To connect . Because the natural connection and related condition judgment should be established at the same time , So you have to use AND Connect .

【2017 The year is a true topic 35 topic : green 】
35. Convert the algebraic equivalent relation to SQL The statement is as follows : SELECT A1,A4 FROM R,S WHERE R.A2 <‘2017’(45); (45)
A. Insert picture description here
B. Insert picture description here
C. Insert picture description here
D. Insert picture description here

answer : The answer is C.

2018 Comprehensive knowledge over the years (0 branch )

2019 Comprehensive knowledge over the years (4 branch )

【2019 The year is a true topic 28 topic : green 】
28、 Given the relational schema R<U,F>, among : Property set U = {A,B,C,D,E}, Functional dependency set F={AC→B,B→DE}. Relationship R( ), And there are ( ).
A、 Only 1 Candidate keywords AC
B、 Only 1 Candidate keywords AB
C、 Yes 2 Candidate keywords AC and BC
D、 Yes 2 Candidate keywords AC and AB

A、1 Two non primary properties and 4 There are two main attributes
B、2 Two non primary properties and 3 There are two main attributes
C、3 Two non primary properties and 2 There are two main attributes
D、4 Two non primary properties and 1 There are two main attributes

answer : The answer is A|C. Investigate the normalization theory of relational database . Send questions .

【2019 The year is a true topic 29 topic : green 】
29、 To add a department table Demp in name Column is given to the user Ming, And allow Ming Grant the limit to others , Realized SQL The statement is as follows :
GRANT( )ON TABLE Demp TO Ming( )
A、SELECT(name)
B、UPDATE(name)
C、INSERT(name)
D、ALL PRIVILEGES(name)

A、FOR ALL
B、CASCADE
C、WITH GRANT OPTION
D、WITH CHECK OPTION

answer : The answer is B|C. Examine the principles of database SQL sentence . It seems SQL Sentences will also be tested in the morning .

  1. SQL In language ,Grant For authorization statements , Its grammar rule is :
  2. Grant< jurisdiction >on Table name [( Name )]to user With grant option.
  3. Possible permissions are :
    1. SELECT: Access the declared table / All columns of the view / Field .
    2. INSERT: Insert all column fields into the declared table .
    3. UPDATE: Update all columns of the declared table / Field .
    4. DELETE: Delete all rows from the declared table .
    5. RULE: In the table / Define rules on the view .
    6. ALL: Give all authority to .
  4. When granting permission , With an additional option , The options include :
    1. CHARACTERSET: The declared character set is allowed
    2. COLLATION: A declared collection sequence is allowed .
    3. TRANSLATION: Allow conversion using declared character sets .
    4. DOMAIN: Declared domains are allowed .
    5. WITH GRANT OPTION: Allow others to be given the same authority .

2020 Next, the real problem of comprehensive knowledge over the years (4 branch )

【2020 The second part is the true question 26 topic : green 】
26. If business TI Data pair D1 It has been locked , Business T2 T2 Data pair D2 Shared lock applied , that ().
A. Business T Data pair D2 Add shared lock successfully , Fail to lock it : Business T2 Data pair D Add shared lock successfully 、 Fail to lock it
B. Business T Data pair D2 Both exclusive lock and shared lock failed : Business T2 Data pair D1 Add shared lock successfully 、 Fail to lock it
C. Business TI Data pair D2 Failed to add shared lock , It's locked successfully : Business T, Data pair D, Add shared lock successfully 、 Fail to lock it
D. Business T Data pair D2 Add shared lock successfully , Fail to lock it : Business T2 Data pair D1 Adding shared lock and exclusive lock failed

answer : The answer is D. Send questions . This is a test of the blockade agreement .
Shared lock (S lock ): Also called read lock , If business T For data objects A add S lock , Other affairs can only be right again A Add S lock , Instead of X lock , until T Release A Upper S lock .
Exclusive lock (X lock ): Also known as write lock . If business T For data objects A add X lock , Other affairs can no longer be right A Add any locks , until T Release A The lock on the .
Because business TI Data pair D1 It has been locked , Then other affairs can no longer be right D1 Add any locks , until T1 Release D1 The lock on the . It can be ruled out directly ABC Three options . Business T2 Data pair D2 Shared lock applied , therefore , Other affairs can only be right again D2 Add shared lock , Not exclusive lock , until T Release A Shared lock on , therefore D That's right

【2020 The second part is the true question 27 topic : green 】
27. Given the relational schema R< U,F>, among : Property set U={A,B,C,D,E,G}, Functional dependency set F={A→BC,C->D,AE→G}. because ( )=U, And satisfy the minimality , So it is R The candidate code for ; If the R It is decomposed into the following two modes (), Then the decomposed relational schema remains functional dependency .
A.AB
B.AD
C.AE
D.CD

A.R(A,B,C) and R2(D,E,G)
B.R(B,C,D,E) and R2(A,E,G)
C.R(B,C,D) and R2(A,E,G)
D.R(A,B,C,D) and R2(A,E,G)

answer : The answer is C|D.
The first blank of this question is the examination of candidate keywords .
Can be analyzed graphically , The degree of 0 The attribute set of is {A,E} Start through this collection , You can traverse the whole graph .
It can also be done through (X)¬+ F=Y Closure analysis :
First step : Let the property set that will eventually become a closure be Y, hold Y Initialize to X;
The second step : Check F Every function in depends on A→B, If the property set A All properties in are in Y in , and B Some properties in are not in Y in , Then add it to Y in ;
The third step : Repeat step 2 , Until no properties can be added to the property set Y So far as . final Y Namely X+
A Options (AB)+ F according to A→BC,C→D Available (AB)+ F ={A,B,C,D} ,
B Options (AD)+ F according to A→BC Available (AD)+ F ={A,B,C,D} ,
C Options (AE)+ F according to A→BC,C→D,AE→G Available (A)+ F={A,B,C,D, E, G}=U ,
D Options (CD)+ F according to C→D Available (CD)+ F ={C,D}. So the first 1 The answer is C.
The second space of this question is the examination of pattern decomposition .
A Options : decompose R1(A,B,C) and R2(D,E,G), Available F1={A→BC},F2 It's empty , therefore F=F1+F2={ A→BC }, Missing functional dependencies C→D,AE→G, Therefore, the decomposed relational pattern does not maintain functional dependency .
B Options : decompose R1(B,C,D,E) and R{(A,E,G), Available F1={C→D},F2={ AE→G }, therefore F=F1+F2={ C→D ,AE→G }, Missing functional dependencies A→BC, Therefore, the decomposed relational pattern does not maintain functional dependency .
C Options : decompose R1(B,C,D) and R2(A,E,G), Available F1={C→D},F2={ AE→G }, therefore F=F1+F2={ C→D ,AE→G }, Missing functional dependencies A→BC, Therefore, the decomposed relational pattern does not maintain functional dependency .
D Options : decompose R1(A,B,C,D) and R2(A,E,G), Available F1={ A→BC,C→D},F2={ AE→G }, therefore F=F1+F2={ A→BC,C→D ,AE→G }, No missing functional dependencies , Therefore, the decomposed relational pattern remains functionally dependent .

【2020 The second part is the true question 28 topic : green 】
28. take Teachers The query permission of the table is granted to the user U1 and U2, And allow the user to grant this permission to other users . To achieve this function SQL The statement is as follows ().
A.GRANT SELECT ON TABLE Teachers TO U1, U2 WITH PUBLIC;
B.GRANT SELECT TO TABLE Teachers ON U1, U2 WITH PUBLIC;
C.GRANT SELECT ON TABLE Teachers TO U1, U2 WITH GRANT OPTION;
D.GRANT SELECT TO TABLE Teachers ON U1, U2 WITH GRANT OPTION;

answer : The answer is C. This question is about authorizing SQL Sentence examination .
SQL Use in grant and revoke Statement to grant or revoke the operation authority of data to the user .
grant Statement grants permission to the user ,revoke Statement to revoke the permission granted to the user .
grant The general format of the statement is :
grant < jurisdiction >[,< jurisdiction >]…on < object type >< Object name >[,< object type >< Object name >]…to < user >[,< user >]…[with grant option] So you can rule out BD Options .
with grant option It means : Confer authority on / Cancellation is cascaded , Such as the with grant option When used for object authorization , The granted user can also grant this object permission to other users or roles , But the administrator takes it back with grant option When authorizing user object permissions , Permissions will be invalidated by propagation . and WITH PUBLIC Yes, you can assign permissions to all users , Give a matrix C Options .

原网站

版权声明
本文为[A volley of attack]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/160/202206090642435001.html