搜档网
当前位置:搜档网 › 数据库系统基础教程(第二版)课后习题答案

数据库系统基础教程(第二版)课后习题答案

数据库系统基础教程(第二版)课后习题答案
数据库系统基础教程(第二版)课后习题答案

Database Systems: The Complete Book Solutions for Chapter 2

Solutions for Section 2.1

Exercise 2.1.1

The E/R Diagram.

Exercise 2.1.8(a)

The E/R Diagram

Kobvxybz

Solutions for Section 2.2

Exercise 2.2.1

The Addresses entity set is nothing but a single address, so we would prefer to make address an attribute of Customers. Were the bank to record several addresses for a customer, then it might make sense to have an Addresses entity set and make Lives-at a many-many relationship.

The Acct-Sets entity set is useless. Each customer has a unique account set containing his or her accounts. However, relating customers directly to their accounts in a many-many relationship conveys the same information and eliminates the account-set concept altogether.

Solutions for Section 2.3

Exercise 2.3.1(a)

Keys ssNo and number are appropriate for Customers and Accounts, respectively. Also, we think it does not make sense for an account to be related to zero customers, so we should round the edge

connecting Owns to Customers. It does not seem inappropriate to have a customer with 0 accounts;

they might be a borrower, for example, so we put no constraint on the connection from Owns to Accounts. Here is the The E/R Diagram,

showing underlined keys and the numerocity constraint.

Exercise 2.3.2(b)

If R is many-one from E1 to E2, then two tuples (e1,e2) and (f1,f2) of the relationship set for R must be the same if they agree on the key attributes for E1. To see why, surely e1 and f1 are the same. Because R is many-one from E1 to E2, e2 and f2 must also be the same. Thus, the pairs are the same.

Solutions for Section 2.4

Exercise 2.4.1

Here is the The E/R Diagram.

We have omitted attributes other than our choice for the key attributes of Students and Courses. Also omitted are names for the relationships. Attribute grade is not part of the key for Enrollments. The key for Enrollements is studID from Students and dept and number from Courses.

Exercise 2.4.4b

Here is the The E/R Diagram Again, we have omitted relationship names and attributes other than our choice for the key attributes. The key for Leagues is its own name; this entity set is not weak. The key for Teams is its own name plus the name of the league of which the team is a part, e.g., (Rangers, MLB) or (Rangers, NHL). The key for Players consists of the player's number and the key for the team on which he or she plays. Since the latter key is itself a pair consisting of team and league names, the key for players is the triple (number, teamName, leagueName). e.g., Jeff

Garcia is (5, 49ers, NFL).

Database Systems: The Complete Book Solutions for Chapter 3

Solutions for Section 3.1

Exercise 3.1.2(a)

We can order the three tuples in any of 3! = 6 ways. Also, the columns can be ordered in any of 3! = 6 ways. Thus, the number of presentations is 6*6 = 36.

Solutions for Section 3.2

Exercise 3.2.1

Customers(ssNo, name, address, phone) Flights(number, day, aircraft)

Bookings(ssNo, number, day , row, seat)

Being a weak entity set, Bookings' relation has the keys for Customers and Flights and Bookings' own attributes.

Notice that the relations obtained from the toCust and toFlt relationships are unnecessary . They are:

toCust(ssNo, ssNo1, number, day)

toFlt(ssNo, number, day, number1, day1)

That is, for toCust, the key of Customers is paired with the key for Bookings. Since both include ssNo, this attribute is repeated with two different names, ssNo and ssNo1. A similar situation exists for toFlt.

Exercise 3.2.3

Ships(name, yearLaunched) SisterOf(name, sisterName)

Solutions for Section 3.3

Exercise 3.3.1

Since Courses is weak, its key is number and the name of its department. We do not have

a

relation for GivenBy. In part (a), there is a relation for Courses and a relation for LabCourses that has only the key and the computer-allocation attribute. It looks like:

Depts(name, chair)

Courses(number, deptName, room)

LabCourses(number, deptName, allocation)

For part (b), LabCourses gets all the attributes of Courses, as:

Depts(name, chair)

Courses(number, deptName, room)

LabCourses(number, deptName, room, allocation)

And for (c), Courses and LabCourses are combined, as:

Depts(name, chair)

Courses(number, deptName, room, allocation)

Exercise 3.3.4(a)

There is one relation for each entity set, so the number of relations is e. The relation for the root entity set has a attributes, while the other relations, which must include the key attributes, have a+k attributes.

Solutions for Section 3.4

Exercise 3.4.2

Surely ID is a key by itself. However, we think that the attributes x, y, and z together form another key. The reason is that at no time can two molecules occupy the same point.

Exercise 3.4.4

The key attributes are indicated by capitalization in the schema below:

Customers(SSNO, name, address, phone)

Flights(NUMBER, DAY, aircraft)

Bookings(SSNO, NUMBER, DAY, row, seat)

Exercise 3.4.6(a)

The superkeys are any subset that contains A1. Thus, there are 2^{n-1} such subsets, since each of the n-1 attributes A2 through An may independently be chosen in or out.

Solutions for Section 3.5

Exercise 3.5.1(a)

We could try inference rules to deduce new dependencies until we are satisfied we have them all.

A more systematic way is to consider the closures of all 15 nonempty sets of attributes.

For the single attributes we have A+ = A, B+ = B, C+ = ACD, and D+ = AD. Thus, the only new dependency we get with a single attribute on the left is C->A.

Now consider pairs of attributes:

AB+ = ABCD, so we get new dependency AB->D. AC+ = ACD, and AC->D is nontrivial. AD+ = AD, so nothing new. BC+ = ABCD, so we get BC->A, and BC->D. BD+ = ABCD, giving us

BD->A and BD->C. CD+ = ACD, giving CD->A.

For the triples of attributes, ACD+ = ACD, but the closures of the other sets are each ABCD. Thus, we get new dependencies ABC->D, ABD->C, and BCD->A.

Since ABCD+ = ABCD, we get no new dependencies.

The collection of 11 new dependencies mentioned above is: C->A, AB->D, AC->D, BC->A, BC->D, BD->A, BD->C, CD->A, ABC->D, ABD->C, and BCD->A.

Exercise 3.5.1(b)

From the analysis of closures above, we find that AB, BC, and BD are keys. All other sets either do not have ABCD as the closure or contain one of these three sets.

Exercise 3.5.1(c)

The superkeys are all those that contain one of those three keys. That is, a superkey that is not a key must contain B and more than one of A, C, and D. Thus, the (proper) superkeys are ABC, ABD, BCD, and ABCD.

Exercise 3.5.3(a)

We must compute the closure of A1A2...AnC. Since A1A2...An->B is a dependency, surely B is in this set, proving A1A2...AnC->B.

Exercise 3.5.4(a)

Consider the relation

This relation satisfies A->B but does not satisfy B->A.

Exercise 3.5.8(a)

If all sets of attributes are closed, then there cannot be any nontrivial functional dependenc ies. For suppose A1A2...An->B is a nontrivial dependency. Then A1A2...An+ contains B and thus A1A2...An is not closed.

Exercise 3.5.10(a)

We need to compute the closures of all subsets of {ABC}, although there is no need to think about the empty set or the set of all three attributes. Here are the calculations for the remaining six sets: A+ = A

B+ = B

C+ = ACE

AB+ = ABCDE

AC+ = ACE

BC+ = ABCDE

We ignore D and E, so a basis for the resulting functional dependencies for ABC are: C->A and AB->C. Note that BC->A is true, but follows logically from C->A, and therefore may be omitted from our list.

Solutions for Section 3.6

Exercise 3.6.1(a)

In the solution to Exercise 3.5.1 we found that there are 14 nontrivial dependencies, including the three given ones and 11 derived dependencies. These are: C->A, C->D, D->A, AB->D, AB-> C, AC->D, BC->A, BC->D, BD->A, BD->C, CD->A, ABC->D, ABD->C, and BCD->A.

We also learned that the three keys were AB, BC, and BD. Thus, any dependency above that does not have one of these pairs on the left is a BCNF violation. These are: C->A, C->D, D->A, AC->D, and CD->A.

One choice is to decompose using C->D. That gives us ABC and CD as decomposed relations. CD is surely in BCNF, since any two-attribute relation is. ABC is not in BCNF, since AB and BC are its only keys, but C->A is a dependency that holds in ABCD and therefore holds in ABC. We must further decompose ABC into AC and BC. Thus, the three relations of the decomposition are AC, BC, and CD.

Since all attributes are in at least one key of ABCD, that relation is already in 3NF, and no decomposition is necessary.

Exercise 3.6.1(b)

(Revised 1/19/02) The only key is AB. Thus, B->C and B->D are both BCNF violations. The derived FD's BD->C and BC->D are also BCNF violations. However, any other nontrivial, derived FD will have A and B on the left, and therefore will contain a key.

One possible BCNF decomposition is AB and BCD. It is obtained starting with any of the four violations mentioned above. AB is the only key for AB, and B is the only key for BCD.

Since there is only one key for ABCD, the 3NF violations are the same, and so is the decomposition.

Solutions for Section 3.7

Exercise 3.7.1

Since A->->B, and all the tuples have the same value for attribute A, we can pair the B-value from any tuple with the value of the remaining attribute C from any other tuple. Thus, we know that R must have at least the nine tuples of the form (a,b,c), where b is any of b1, b2, or b3, and c is any of c1, c2, or c3. That is, we can derive, using the definition of a multivalued dependency, that each of the tuples (a,b1,c2), (a,b1,c3), (a,b2,c1), (a,b2,c3), (a,b3,c1), and (a,b3,c2) are also in R.

Exercise 3.7.2(a)

First, people have unique Social Security numbers and unique birthdates. Thus, we expect the functional dependencies ssNo->name and ssNo->birthdate hold. The same applies to children, so we expect childSSNo->childname and childSSNo->childBirthdate. Finally, an automobile has a unique brand, so we expect autoSerialNo->autoMake.

There are two multivalued dependencies that do not follow from these functional dependencies. First, the information about one child of a person is independent of other information about that person. That is, if a person with social security number s has a tuple with cn,cs,cb, then if there is

any other tuple t for the same person, there will also be another tuple that agrees with t except that it has cn,cs,cb in its components for the child name, Social Security number, and birthdate. That is the multivalued dependency

ssNo->->childSSNo childName childBirthdate

Similarly, an automobile serial number and make are independent of any of the other attributes, so we expect the multivalued dependency

ssNo->->autoSerialNo autoMake

The dependencies are summarized below:

ssNo -> name birthdate

childSSNo -> childName childBirthdate

autoSerialNo -> autoMake

ssNo ->-> childSSNo childName childBirthdate

ssNo ->-> autoSerialNo autoMake

Exercise 3.7.2(b)

We suggest the relation schemas

{ssNo, name, birthdate}

{ssNo, childSSNo}

{childSSNo, childName childBirthdate}

{ssNo, autoSerialNo}

{autoSerialNo, autoMake}

An initial decomposition based on the two multivalued dependencies would give us {ssNo, name, birthDate}

{ssNo, childSSNo, childName, childBirthdate}

{ssNo, autoSerialNo, autoMake}

Functional dependencies force us to decompose the second and third of these.

Exercise 3.7.3(a)

Since there are no functional dependencies, the only key is all four attributes, ABCD. Thus, each of the nontrvial multivalued dependencies A->->B and A->->C violate 4NF. We must separate out the attributes of these dependencies, first decomposing into AB and ACD, and then decomposing the latter into AC and AD because A->->C is still a 4NF violation for ACD. The final set of relations are AB, AC, and AD.

Exercise 3.7.7(a)

Let W be the set of attributes not in X, Y, or Z. Consider two tuples xyzw and xy'z'w' in the relation R in question. Because X ->-> Y, we can swap the y's, so xy'zw and xyz'w' are in R. Because X ->-> Z, we can take the pair of tuples xyzw and xyz'w' and swap Z's to get xyz'w and xyzw'. Similarly, we can take the pair xy'z'w' and xy'zw and swap Z's to get xy'zw' and xy'z'w.

In conclusion, we started with tuples xyzw and xy'z'w' and showed that xyzw' and xy'z'w must also be in the relation. That is exactly the statement of the MVD X ->-> Y-union-Z. Note that the above statements all make sense even if there are attributes in common among X, Y, and Z.

Exercise 3.7.8(a)

Consider a relation R with schema ABCD and the instance with four tuples abcd, abcd', ab'c'd, and ab'c'd'. This instance satisfies the MVD A->-> BC. However, it does not satisfy A->-> B. For example, if it did satisfy A->-> B, then because the instance contains the tuples abcd and ab'c'd, we would expect it to contain abc'd and ab'cd, neither of which is in the instance.

Solutions for Chapter 4

Solutions for Section 4.2

Exercise 4.2.1

class Customer {

attribute string name;

attribute string addr;

attribute string phone;

attribute integer ssNo;

relationship Set ownsAccts

inverse Account::ownedBy;

}

class Account {

attribute integer number;

attribute string type;

attribute real balance;

relationship Set ownedBy

inverse Customer::ownsAccts

}

Exercise 4.2.4

class Person {

attribute string name;

relationship Person motherOf

inverse Person::childrenOfFemale

relationship Person fatherOf

inverse Person::childrenOfMale

relationship Set children

inverse Person::parentsOf

relationship Set childrenOfFemale

inverse Person::motherOf

relationship Set childrenOfMale

inverse Person::fatherOf

relationship Set parentsOf

inverse Person::children

}

Notice that there are six different relationships here. For example, the inverse of the relationship that connects a person to their (unique) mother is a relationship that connects a mother (i.e., a female person) to the set of her children. That relationship, which we call childrenOfFemale, is different from the children relationship, which connects anyone -- male or female -- to their children.

Exercise 4.2.7

A relationship R is its own inverse if and only if for every pair (a,b) in R, the pair (b,a) is also in R. In the terminology of set theory, the relation R is ``symmetric.''

Solutions for Section 4.3

Exercise 4.3.1

We think that Social Security number should me the key for Customer, and account number should be the key for Account. Here is the ODL solution with key and extent declarations.

class Customer

(extent Customers key ssNo)

{

attribute string name;

attribute string addr;

attribute string phone;

attribute integer ssNo;

relationship Set ownsAccts

inverse Account::ownedBy;

}

class Account

(extent Accounts key number)

{

attribute integer number;

attribute string type;

attribute real balance;

relationship Set ownedBy

inverse Customer::ownsAccts

}

Solutions for Section 4.4

Exercise 4.4.1(a)

Since the relationship between customers and accounts is many-many, we should create a separate relation from that relationship-pair.

Customers(ssNo, name, address, phone)

Accounts(number, type, balance)

CustAcct(ssNo, number)

Exercise 4.4.1(d)

Ther is only one attribute, but three pairs of relationships from Person to itself. Since motherOf and fatherOf are many-one, we can store their inverses in the relation for Person. That is, for each person, childrenOfMale and childrenOfFemale will indicate that persons's father and mother. The children relationship is many-many, and requires its own relation. This relation actually turns out to be redundant, in the sense that its tuples can be deduced from the relationships stored with Person. The schema:

Persons(name, childrenOfFemale, childrenOfMale)

Parent-Child(parent, child)

Exercise 4.4.4

Y ou get a schema like:

Studios(name, address, ownedMovie)

Since name -> address is the only FD, the key is {name, ownedMovie}, and the FD has a left side that is not a superkey.

Exercise 4.4.5(a,b,c)

(a) Struct Card { string rank, string suit };

(b) class Hand {

attribute Set theHand;

};

For part (c) we have:

Hands(handId, rank, suit)

Notice that the class Hand has no key, so we need to create one: handID. Each hand has, in the relation Hands, one tuple for each card in the hand.

Exercise 4.4.5(e)

Struct PlayerHand { string Player, Hand theHand };

class Deal {

attribute Set theDeal;

}

Alternatively, PlayerHand can be defined directly within the declaration of attribute theDeal. Exercise 4.4.5(h)

Since keys for Hand and Deal are lacking, a mechanical way to design the database schema is to have one relation connecting deals and player-hand pairs, and another to specify the contents of hands. That is:

Deals(dealID, player, handID)

Hands(handID, rank, suit)

However, if we think about it, we can get rid of handID and connect the deal and the player directly to the player's cards, as:

Deals(dealID, player, rank, suit)

Exercise 4.4.5(i)

First, card is really a pair consisting of a suit and a rank, so we need two attributes in a relation schema to represent cards. However, much more important is the fact that the proposed schema does not distinguish which card is in which hand. Thus, we need another attribute that indicates which hand within the deal a card belongs to, something like:

Deals(dealID, handID, rank, suit)

Exercise 4.4.6(c)

Attribute b is really a bag of (f,g) pairs. Thus, associated with each a-value will be zero or more (f,g) pairs, each of which can occur several times. We shall use an attribute count to indicate the number of occurrences, although if relations allow duplicate tuples we could simply allow duplicate (a,f,g) triples in the relation. The proposed schema is:

C(a, f, g, count)

Solutions for Section 4.5

Exercise 4.5.1(b)

Studios(name, address, movies{(title, year, inColor, length,

stars{(name, address, birthdate)})})

Since the information about a star is repeated once for each of their movies, there is redundancy. To eliminate it, we have to use a separate relation for stars and use pointers from studios. That is: Stars(name, address, birthdate)

Studios(name, address, movies{(title, year, inColor, length,

stars{*Stars})})

Since each movie is owned by one studio, the information about a movie appears in only one tuple of Studios, and there is no redundancy.

Exercise 4.5.2

Customers(name, address, phone, ssNo, accts{*Accounts})

Accounts(number, type, balance, owners{*Customers})

Solutions for Section 4.6

Exercise 4.6.1(a)

We need to add new nodes labeled George Lucas and Gary Kurtz. Then, from the node sw (which represents the movie Star Wars), we add arcs to these two new nodes, labeled directedBy and producedBy, respectively.

Exercise 4.6.2

Create nodes for each account and each customer. From each customer node is an arc to a node representing the attributes of the customer, e.g., an arc labeled name to the customer's name. Likewise, there is an arc from each account node to each attribute of that account, e.g., an arc labeled balance to the value of the balance.

To represent ownership of accounts by customers, we place an arc labeled owns from each customer node to the node of each account that customer holds (possibly jointly). Also, we place

an arc labeled ownedBy from each account node to the customer node for each owner of that account.

Exercise 4.6.5

In the semistructured model, nodes represent data elements, i.e., entities rather than entity sets. In the E/R model, nodes of all types represent schema elements, and the data is not represented at all. Solutions for Section 4.7

Exercise 4.7.1(a)

Carrie Fisher

123 Maple St.

Hollywood

5 Locust Ln.

Malibu

Mark Hamill

456 Oak Rd.

Brentwood

Harrison Ford

whatever

whatever

Star Wars

1977

Empire Strikes Back

1980

Return of the Jedi

1983

Witness

1985

Exercise 4.7.2

custId ID

owns IDREFS>

acctId ID

ownedBy IDREFS>

]>

Database Systems: The Complete Array Book

Solutions for Chapter 5

Solutions for Section 5.2

Exercise 5.2.1(a)

PI_model( SIGMA_{speed >= 1000} ) (PC)

Exercise 5.2.1(f)

The trick is to theta-join PC with itself on the condition that the hard disk sizes are equal. That gives us tuples that have two PC model numbers with the same value of hd. However, these two PC's could in fact be the same, so we must also require in the theta-join that the model numbers be unequal. Finally, we want the hard disk sizes, so we project onto hd.

The expression is easiest to see if we write it using some temporary values. We start by renaming PC twice so we can talk about two occurrences of the same attributes.

R1 = RHO_{PC1} (PC)

R2 = RHO_{PC2} (PC)

R3 = R1 JOIN_{PC1.hd = PC2.hd AND PC1.model <> PC2.model} R2

R4 = PI_{PC1.hd} (R3)

Exercise 5.2.1(h)

First, we find R1, the model-speed pairs from both PC and Laptop. Then, we find from R1 those computers that are ``fast,'' at least 133Mh. At the same time, we join R1 with Product to connect model numbers to their manufacturers and we project out the speed to get R2. Then we join R2 with itself (after renaming) to find pairs of different models by the same maker. Finally, we get our answer, R5, by projecting onto one of the maker attributes. A sequence of steps giving the desired expression is: R1 = PI_{model,speed} (PC) UNION PI_{model,speed} (Laptop)

R2 = PI_{maker,model} (SIGMA_{speed>=700} (R1) JOIN Product)

R3 = RHO_{T(maker2, model2)} (R2)

R4 = R2 JOIN_{maker = maker2 AND model <> model2} (R3)

R5 = PI_{maker} (R4)

Exercise 5.2.2

Here are figures for the expression trees of Exercise 5.2.1 Part (a)Part (f)Part (h). Note that the third figure is not really a tree, since it uses a common subexpression. We could duplicate the nodes to make it a tree, but using common subexpressions is a valuable form of query optimization. One of the benefits one gets from constructing ``trees'' for queries is the ability to combine nodes that represent common subexpressions.

Exercise 5.2.7

The relation that results from the natural join has only one attribute from each pair of equated attributes. The theta-join has attributes for both, and their columns are identical.

Exercise 5.2.9(a)

If all the tuples of R and S are different, then the union has n+m tuples, and this number is the maximum possible.

The minimum number of tuples that can appear in the result occurs if every tuple of one relation also appears in the other. Surely the union has at least as many tuples as the larger of R and that is, max(n,m) tuples. However, it is possible for every tuple of the smaller to appear in the other, so it is possible that there are as few as max(n,m) tuples in the union.

Exercise 5.2.10

In the following we use the name of a relation both as its instance (set of tuples) and as its schema (set of attributes). The context determines uniquely which is meant.

PI_R(R JOIN S) Note, however, that this expression works only for sets; it does not preserve the multipicity of tuples in R. The next two expressions work for bags.

R JOIN DELTA(PI_{R INTERSECT S}(S)) In this expression, each projection of a tuple from S onto the attributes that are also in R appears exactly once in the second argument of the join, so it preserves multiplicity of tuples in R, except for those that

do not join with S, which disappear. The DELTA operator removes duplicates, as described in Section 5.4.

R - [R - PI_R(R JOIN S)] Here, the strategy is to find the dangling tuples of R and remove them.

Solutions for Section 5.3

Exercise 5.3.1

As a bag, the value is {700, 1500, 866, 866, 1000, 1300, 1400, 700, 1200, 750, 1100, 350, 733}. The order is unimportant, of course. The average is 959.

As a set, the value is {700, 1500, 866, 1000, 1300, 1400, 1200, 750, 1100, 350, 733}, and the average is 967. H3>Exercise 5.3.4(a)

As sets, an element x is in the left-side expression

(R UNION S) UNION T

if and only if it is in at least one of R, S, and T. Likewise, it is in the right-side expression

R UNION (S UNION T)

under exactly the same conditions. Thus, the two expressions have exactly the same members, and the sets are equal.

As bags, an element x is in the left-side expression as many times as the sum of the number of times it is in R, S, and T. The same holds for the right side. Thus, as bags the expressions also have the same value.

Exercise 5.3.4(h)

As sets, element x is in the left side

R UNION (S INTERSECT T)

if and only if x is either in R or in both S and T. Element x is in the right side

(R UNION S) INTERSECT (R UNION T)

if and only if it is in both R UNION S and R UNION T. If x is in R, then it is in both unions. If x is in both S and T, then it is in both union. However, if x is neither in R nor in both of S and T, then it cannot be in both unions. For example, suppose x is not in R and not in S. Then x is not in R UNION S. Thus, the statement of when x is in the right side is exactly the same as when it is in the left side: x is either in R or in both of S and T.

Now, consider the expression for bags. Element x is in the left side the sum of the number of times it is in R plus the smaller of the number of times x is in S and the number of times x is in T. Likewise, the number of times x is in the right side is the smaller of

The sum of the number of times x is in R and in S.

The sum of the number of times x is in R and in T.

A moment's reflection tells us that this minimum is the sum of the number of times x is in R plus the smaller of the number of times x is in S and in T, exactly as for the left side.

Exercise 5.3.5(a)

For sets, we observe that element x is in the left side

(R INTERSECT S) - T

if and only if it is in both R and S and not in T. The same holds for the right side

R INTERSECT (S-T)

so as sets, the equivalence holds.

Now suppose we have bags. Let R = {x}, S = {x,x}, and T = {x}. Then R INTERSECT S = {x}, and the left side is {x}-{x}, or EMPTYSET.

However, on the right, S-T = {x}, so the right side is {x} INTERSECT {x}, which is {x}.

Solutions for Section 5.4

Exercise 5.4.1(a)

{(1,0,1), (5,4,9), (1,0,1), (6,4,16), (7,9,16)}.

Exercise 5.4.1(c)

The result is the list [(0,1), (0,1), (2,3), (2,4), (3,4)].

Exercise 5.4.1(e)

{(0,1), (2,3), (2,4), (3,4)}.

Exercise 5.4.1(g)

{(0,2), (2,7), (3,4)}.

Exercise 5.4.1(k)

Exercise 5.4.2(a)

When a relation has no duplicate tuples, DELTA has no effect on it. Thus, DELTA is idempotent.

Exercise 5.4.2(b)

The result of PI_L is a relation over the list of attributes L. Projecting this relation onto L has no effect, so PI_L is idempotent.

Exercise 5.4.3

If we use set semantics, it is not hard to get the effect of PI_{A,A}using only the operators of Section 5.1. The idea is to project R onto A, take the product of that relation with itself, and select for equality. As a sequence of steps:

R1(A) := PI_A(R)

R2(A,A1) := R1 * RHO_{S(A1)}(R1)

ANS(A,A1) := SIGMA_{A=A1}(R2)

Under bag semantics, it is not possible. The intuitive idea behind the proof is that: Focus on the case when R consists only of two tuples, each of which is (0,1). e neec to produce the result {(0,0), (0,0)}.

Since joins can be expressed as products, selections, and projections, let us assume

that the only operations used are selection, projection, product, union, intersection, and difference.

We can never get a relation with tuples that have two 0's in different components without using a product. However, then we get at least four identical tuples (or none, if we have eliminated the 0's) with two 0's.

No operation can distinguish among them, so they all survive any operation, or none do.

Thus, we can never produce a result with exactly two tuples with two 0 components. Solutions for Section 5.5

Exercise 5.5.1(a)

SIGMA_{speed<1000 AND price>1500} (PC) = EMPTYSET

Exercise 5.5.1(d)

This complex expression is best seen as a sequence of steps in which we define temporary relations R1 through R4 that stand for nodes of expression trees. Here is the sequence:

R1(maker, model, speed) := PROJ_{maker,model,speed}(Product JOIN PC)

R2(maker, speed) := PROJ_{maker,speed}(Product JOIN Laptop)

R3(model) := PROJ_{model}(R1 JOIN_{R1.maker=R2.maker AND

R1.speed<=R2.speed} R2)

R4(model) := PROJ_{model}(PC)

The constraint is that R4 is a subset of R3.

In explanation, R1 is the set of maker-model-speed triples for PC's, and R2 is the set of maker-speed pairs for laptops. Note JOIN is the natural join. R3 is the set of models (of PC's) for which there is a laptop by the same manufacturer at least as fast. R4 is all the PC models. Note that R3 is surely a subset of R4, so the constraint that R4 be a subset of R3 is really asking that these sets be equal; i.e., every PC has a laptop by the same manufacturer that is at least as fast.

Database Systems: The Complete Array Book

Solutions for Chapter 6

Revised 11/3/01.

Solutions for Section 6.1

Exercise 6.1.1

If they are two different attributes, there will be a comma between them. Remember, in SQL, two names with no punctuation between them usually indicates that the second is an alias for the first.

Exercise 6.1.2(a)

SELECT address

FROM Studio

WHERE name = 'MGM';

Exercise 6.1.2(c)

If you interpret the question as asking only that Love appear as a substring, then the following is OK:

SELECT starName

FROM StarsIn

WHERE movieYear = 1980 OR movieTitle LIKE '%Love%';

However, another reasonable interpretation is that we want the word Love as a word by itself. The query above returns stars of a movie like The Cook, the Thief, His Wife, and Her Lover. To identify only titles that have Love as a word by itself, either at the beginning, the middle, the endor as the entire title, we need to use four patterns. The following query works; notice the judiciously placed blanks in the patterns. SELECT starName

FROM StarsIn

WHERE movieYear = 1980 OR

movieTitle LIKE 'Love %' OR

movieTitle LIKE '% Love %' OR

movieTitle LIKE '% Love' OR

movieTitle = 'Love';

Exercise 6.1.3(a)

SELECT model, speed, hd

FROM PC

WHERE price < 1200;

The result:

Exercise 6.1.3(b)

SELECT model, speed AS megahertz, hd AS gigabytes

FROM PC

WHERE price < 1200;

Exercise 6.1.3(e)

SELECT *

FROM Printer

WHERE color;

The result:

Exercise 6.1.5(a)

All tuples where either a is 10 or b is 20, or both. There is no restriction on where NULL may appear, except for the above condition.

Exercise 6.1.5(d)

All tuples where a and b have the same, nonnull value.

Solutions for Section 6.2

Exercise 6.2.1(a)

SELECT name

FROM MovieStar, StarsIn

WHERE gender = 'M' AND

name = starName AND

movieTitle = 'Terms of Endearment';

Exercise 6.2.1(d)

SELECT M1.title

FROM Movie AS M1, Movie AS M2

WHERE M2.title = 'Gone With the Wind' AND

M1.length > M2.length;

Exercise 6.2.2(a)

SELECT maker, speed

FROM Product, Laptop

WHERE hd >= 30 AND

Product.model = Laptop.model;

Exercise 6.2.2(b)

We need to join Product with each of the other three relations and take the union.

(SELECT Product.model, price

FROM Product, PC

WHERE Product.model = PC.model AND

maker = 'B')

UNION

(SELECT Product.model, price

FROM Product, Laptop

WHERE Product.model = Laptop.model AND

maker = 'B')

UNION

(SELECT Product.model, price

FROM Product, Printer

WHERE Product.model = Printer.model AND

maker = 'B');

数据库系统原理教程课后习题答案

第1章绪论 1 .试述数据、数据库、数据库系统、数据库管理系统得概念。 答: ( l )数据( Data):描述事物得符号记录称为数据。数据得种类有数字、文字、图形、图像、声音、正文等。数据与其语义就是不可分得。解析在现代计算机系统中数据得概念就是广义得。早期得计算机系统主要用于科学计算,处理得数据就是整数、实数、浮点数等传统数学中得数据。现代计算机能存储与处理得对象十分广泛,表示这些对象得数据也越来越复杂。数据与其语义就是不可分得。500 这个数字可以表示一件物品得价格就是500元,也可以表示一个学术会议参加得人数有500 人,还可以表示一袋奶粉重500 克。(2)数据库( DataBase,简称DB) :数据库就是长期储存在计算机内得、有组织得、可共享得数据集合。数据库中得数据按一定得数据模型组织、描述与储存,具有较小得冗余度、较高得数据独立性与易扩展性,并可为各种用户共享。 ( 3 )数据库系统(DataBas。Sytem ,简称DBS):数据库系统就是指在计算机系统中引入数据库后得系统构成,一般由数据库、数据库管理系统(及其开发工具)、应用系统、数据库管理员构成。解析数据库系统与数据库就是两个概念。数据库系统就是一个人一机系统,数据库就是数据库系统得一个组成部分。但就是在日常工作中人们常常把数据库系统简称为数据库。希望读者能够从人们讲话或文章得上下文中区分“数据库系统”与“数据库”,不要引起混淆。 ( 4 )数据库管理系统( DataBase Management sytem,简称DBMs ):数据库管理系统就是位于用户与操作系统之间得一层数据管理软件,用于科学地组织与存储数据、高效地获取与维护数据。DBMS 得主要功能包括数据定义功能、数据操纵功能、数据库得运行管理功能、数据库得建立与维护功能。解析DBMS 就是一个大型得复杂得软件系统,就是计算机中得基础软件。目前,专门研制DBMS 得厂商及其研制得DBM S产品很多。著名得有美国IBM 公司得DBZ 关系数据库管理系统与IMS层次数据库管理系统、美国Oracle 公司得orade 关系数据库管理系统、s油ase 公司得s 油ase关系数据库管理系统、美国微软公司得SQL Serve ,关系数据库管理系统等。 2 .使用数据库系统有什么好处? 答: 使用数据库系统得好处就是由数据库管理系统得特点或优点决定得。使用数据库系统得好处很多,例如,可以大大提高应用开发得效率,方便用户得使用,减轻数据库系统管理人员维护得负担,等等。使用数据库系统可以大大提高应用开发得效率。因为在数据库系统中应用程序不必考虑数据得定义、存储与数据存取得具体路径,这些工作都由DBMS来完成。用一个通俗得比喻,使用了DBMS 就如有了一个好参谋、好助手,许多具体得技术工作都由这个助手来完成。开发人员就可以专注于应用逻辑得设计,而不必为数据管理得许许多多复杂得细节操心。还有,当应用逻辑改变,数据得逻辑结构也需要改变时,由于数据库系统提供了数据与程序之间得独立性,数据逻辑结构得改变就是DBA 得责任,开发人员不必修改应用程序,或者只需要修改很少得应用程序,从而既简化了应用程序得编制,又大大减少了应用程序得维护与修改。使用数据库系统可以减轻数据库系统管理人员维护系统得负担。因为DBMS 在数据库建立、运用与维护时对数据库进行统一得管理与控制,包括数据得完整性、安全性、多用户并发控制、故障恢复等,都由DBMS执行。总之,使用数据库系统得优点就是很多得,既便于数据得集中管理,控制数据冗余,提高数据得利用率与一致性,又有利于应用程序得开发与维护。读者可以在自己今后得工作中结合具体应用,认真加以体会与总结。 3.试述文件系统与数据库系统得区别与联系。 答: 文件系统与数据库系统得区别就是:文件系统面向某一应用程序,共享性差,冗余度大,数据独立性差,记录内有结构,整体无结构,由应用程序自己控制。数据库系统面向现实世界,共享性高,冗余度小,具有较高得物理独立性与一定得逻辑独立性,整体结构化,用数据模型描述,由数据库管理系统提供数据得安全性、完整性、并发控

数据库课后习题答案崔巍版

数据库课后习题答案崔 巍版 Document serial number【KKGB-LBS98YT-BS8CB-BSUT-BST108】

《数据库系统及应用》(第二版)习题解答 习题一 1.什么是数据库 数据库是相互关联的数据的集合,它用综合的方法组织数据,具有较小的数据冗余,可供多个用户共享,具有较高的数据独立性,具有安全控制机制,能够保证数据的安全、可靠,允许并发地使用数据库,能有效、及时地处理数据,并能保证数据的一致性和完整性。 2.简要概述数据库、数据库管理系统和数据库系统各自的含义。 数据库、数据库管理系统和数据库系统是三个不同的概念,数据库强调的是相互关联的数据,数据库管理系统是管理数据库的系统软件,而数据库系统强调的是基于数据库的计算机应用系统。 3.数据独立性的含义是什么 数据独立性是指数据的组织和存储方法与应用程序互不依赖、彼此独立的特性。这种特性使数据的组织和存储方法与应用程序互不依赖,从而大大降低应用程序的开发代价和维护代价。 4.数据完整性的含义是什么 保证数据正确的特性在数据库中称之为数据完整性。 5.简要概述数据库管理员的职责。 数据库管理员的职责可以概括如下: (1)首先在数据库规划阶段要参与选择和评价与数据库有关的计算机软件和硬件,要与数据库用户共同确定数据库系统的目标和数据库应用需求,要确定数据库的开发计划; (2)在数据库设计阶段要负责数据库标准的制定和共用数据字典的研制,要负责各级数据库模式的设计,负责数据库安全、可靠方面的设计; (3)在数据库运行阶段首先要负责对用户进行数据库方面的培训;负责数据库的转储和恢复;负责对数据库中的数据进行维护;负责监视数据库的性能,并调整、改善数据库的性能,提高系统的效率;继续负责数据库安全系统的管理;在运行过程中发现问题、解决问题。 6.文件系统用于数据管理存在哪些明显的缺陷 文件系统用于数据管理明显存在如下缺陷: (1)数据冗余大。这是因为每个文件都是为特定的用途设计的,因此就会造成同样的数据在多个文件中重复存储。 (2)数据不一致性。这往往是由数据冗余造成的,在进行更新时,稍不谨慎就会造成同一数据在不同文件中的不一致。 (3)程序和数据之间的独立性差。应用程序依赖于文件的存储结构,使得若修改文件的存储结构则必须修改程序。 (4)数据联系弱。文件与文件之间是独立的,文件之间的联系必须通过程序来构造。因此,文件系统是一个不具有弹性的、无结构的数据集合,不能反映现实世界事物之间的联系。 习题二 1.数据的三种范畴的含义是什么 数据需要我们的认识、理解、整理、规范和加工,然后才能存放到数据库中。数据从现实生活进入到数据库实际经历了现实世界阶段(认识、理解)、信息世界阶段(规范、提升)和机器世界阶段(管理),我们也把之称为数据的三种范畴,数据在三种范畴中的概念、术语都有些不同。

数据库系统基础教程(第二版)课后习题答案

Database Systems: The Complete Book Solutions for Chapter 2 Solutions for Section 2.1 Exercise 2.1.1 The E/R Diagram. Exercise 2.1.8(a) The E/R Diagram Kobvxybz Solutions for Section 2.2 Exercise 2.2.1 The Addresses entity set is nothing but a single address, so we would prefer to make address an attribute of Customers. Were the bank to record several addresses for a customer, then it might make sense to have an Addresses entity set and make Lives-at a many-many relationship. The Acct-Sets entity set is useless. Each customer has a unique account set containing his or her accounts. However, relating customers directly to their accounts in a many-many relationship conveys the same information and eliminates the account-set concept altogether. Solutions for Section 2.3 Exercise 2.3.1(a) Keys ssNo and number are appropriate for Customers and Accounts, respectively. Also, we think it does not make sense for an account to be related to zero customers, so we should round the edge connecting Owns to Customers. It does not seem inappropriate to have a customer with 0 accounts;

数据库系统应用试题及答案

数据库系统概述 一、概述 1.数据库系统是采用了数据库技术的计算机系统,数据库系统由数据库、数据库管理系统、应用系统和()。 A.系统分析员 B.程序员 C.数据库管理员 D.操作员 2.数据库(DB),数据库系统(DBS)和数据库管理系统(DBMS)之间的关系是()。 A.DBS包括DB和DBMS B.DBMS包括DB和DBS C.DB包括DBS和DBMS D.DBS就是DB,也就是DBMS 3.下面列出的数据库管理技术发展的三个阶段中,没有专门的软件对数据进行管理的是()。 I.人工管理阶段 II.文件系统阶段 III.数据库阶段 A.I 和 II B.只有 II C.II 和 III D.只有 I 4.下列四项中,不属于数据库系统特点的是()。 A.数据共享 B.数据完整性 C.数据冗余度高 D.数据独立性高 5.数据库系统的数据独立性体现在()。 A.不会因为数据的变化而影响到应用程序 B.不会因为数据存储结构与数据逻辑结构的变化而影响应用程序 C.不会因为存储策略的变化而影响存储结构 D.不会因为某些存储结构的变化而影响其他的存储结构 6.描述数据库全体数据的全局逻辑结构和特性的是()。 A.模式 B.内模式 C.外模式 D. 7.要保证数据库的数据独立性,需要修改的是()。 A.模式与外模式 B.模式与内模式 C.三级模式之间的两层映射 D.三层模式 8.要保证数据库的逻辑数据独立性,需要修改的是()。 A.模式与外模式之间的映射 B.模式与内模式之间的映射 C.模式 D.三级模式 9.用户或应用程序看到的那部分局部逻辑结构和特征的描述是()模式。 A.模式 B.物理模式 C.子模式 D.内模式 10.下述()不是DBA数据库管理员的职责。 A.完整性约束说明 B.定义数据库模式 C.数据库安全 D.数据库管理系统设计 11.概念模型是现实世界的第一层抽象,这一类模型中最著名的模型是()。 A.层次模型 B.关系模型 C.网状模型 D.实体-关系模型 <实体-联系图Entity Relationship Diagram 基本要素:实体型属性联系> 12.区分不同实体的依据是()。 A.名称 B.属性 C.对象 D.概念 13.关系数据模型是目前最重要的一种数据模型,它的三个要素分别是()。 A.实体完整性、参照完整性、用户自定义完整性 B.数据结构、关系操作、完整性约束 C.数据增加、数据修改、数据查询 D.外模式、模式、内模式 14.在()中一个结点可以有多个双亲,结点之间可以有多种联系。 A.网状模型 B.关系模型 C.层次模型 D.以上都有 15.()的存取路径对用户透明,从而具有更高的数据独立性、更好的安全保密性,也简化了程序员的工作和数据库开发建立的工作。 A.网状模型 B.关系模型 C.层次模型 D.以上都有

数据库原理课后习题答案

第1章绪论 2 ?使用数据库系统有什么好处? 答:使用数据库系统的优点是很多的,既便于数据的集中管理,控制数据冗余,提高数据的利用率和一致性,又有利于应用程序的开发和维护。 6 .数据库管理系统的主要功能有哪些? 答:(I )数据库定义功能;(2 )数据存取功能; (3 )数据库运行管理;(4 )数据库的建立和维护功能。 8 ?试述概念模型的作用。 答:概念模型实际上是现实世界到机器世界的一个中间层次。概念模型用于信息世界的建模, 是现实世界到信息世界的第一层抽象,是数据库设计人员进行数据库设计的有力工具,也是 数据库设计人员和用户之间进行交流的语言。 12 ?学校中有若干系,每个系有若干班级和教研室,每个教研室有若干教员,其中有的教 授和副教授每人各带若干研究生;每个班有若干学生,每个学生选修若干课程,每门课可由 若干学生选修。请用E —R图画出此学校的概念模型。 答:实体间联系如下图所示,联系-选修有一个属性:成绩。 各实体需要有属性说明,需要画出各实体的图(带属性)或在下图中直接添加实体的属性,比如:学生的属性包括学号、姓名、性别、身高、联系方式等,此略。 13 ?某工厂生产若干产品,每种产品由不同的零件组成,有的零件可用在不同的产品上。 这些零件由不同的原材料制成,不同零件所用的材料可以相同。这些零件按所属的不同产品

分别放在仓库中,原材料按照类别放在若干仓库中。请用 E 一R图画出此工厂产品、零 件、材料、仓库的概念模型。 答:各实体需要有属性,此略。 联系组成、制造、储存、存放都有属性:数量。 20 ?试述数据库系统三级模式结构,这种结构的优点是什么? 答:数据库系统的三级模式结构由外模式、模式和内模式组成。 外模式,亦称子模式或用户模式,是数据库用户(包括应用程序员和最终用户)能够看见和使用的局部数据的逻辑结构和特征的描述,是数据库用户的数据视图,是与某一应用有 关的数据的逻辑表示。 模式,亦称逻辑模式,是数据库中全体数据的逻辑结构和特征的描述,是所有用户的公 共数据视图。模式描述的是数据的全局逻辑结构。外模式涉及的是数据的局部逻辑结构,通 常是模式的子集。 内模式,亦称存储模式,是数据在数据库系统内部的表示,即对数据的物理结构和存储 方式的描述。 数据库系统的三级模式是对数据的三个抽象级别,它把数据的具体组织留给DBMS管理,使用户能逻辑抽象地处理数据,而不必关心数据在计算机中的表示和存储。数据库系统 在这三级模式之间提供了两层映像:外模式/模式映像和模式/内模式映像,这两层映像保 证了数据库系统中的数据能够具有较高的逻辑独立性和物理独立性。 22 ?什么叫数据与程序的物理独立性?什么叫数据与程序的逻辑独立性?为什么数据库系 统具有数据与程序的独立性? 答:数据与程序的逻辑独立性是指用户的的应用程序与数据库的逻辑结构是相互独立的。 数据与程序的物理独立性是指用户的的应用程序与存储在磁盘上的数据库中数据是相互独立的。 当模式改变时(例如增加新的关系、新的属性、改变属性的数据类型等),由数据库管 理员对各个外模式/模式的映像做相应改变,可以使外模式保持不变。应用程序是依据数据的外模式编写的,从而应用程序不必修改,保证了数据与程序的逻辑独立性,简称数据的逻辑独立性。 当数据库的存储结构改变了,由数据库管理员对模式/内模式映像做相应改变,可以使模式保持不变,从而应用程序也不必改变,保证了数据与程序的物理独立性,简称数据的物理独立性。数据库管理系统在三级模式之间提供的两层映像保证了数据库系统中的数据能够具有较高的逻辑独立性和物理独立性。

工程数学基础教程课后习题答案

工程数学基础习题解答

习题一 A

一、判断题 1.√;, 2.√; 3.×; 4.×; 5.×; 6.×; 7.×; 8.√; 9.√;10.×. 二、填空题 1.;C C A B 2.111(){1,2,3,4},(){,,},(){,,},(){1,4},(){2,3};f f a b e f A a b e f B f b --=====D R 3.满; 4.2sup = E ,3inf -=E ; 5.0; 6.0; 7. n ; 8.Y . B 1.证 ()y f A B ?∈?,x A B ?∈?使得)(x f y =.由x A B ∈?,得x A ∈,且x B ∈故()()y f x f A =∈且()y f B ∈,即()()y f A f B ∈?,因此()()()f A B f A f B ???. 当f 是单射时,只需证明()()()f A f B f A B ???即可: ()()(),y f A f B f ?∈??R f 由是单射知,(). (),(),1X y f x y f A y f B x ?=∈∈∈使得且 ,,()(),x A x B x A B y f x f A B ∴∈∈∈?=∈?且即从而故()()()f A f B f A B ???. 是可能的,例如, 2:,[2, 0],[1, 3],[1, 0].f x x A B A B =-=-?=-取则()([1,0])[0, 1], f A B f ?=-=于是而 [][]()()0, 4[0, 9]0, 4.f A f B ?=?=从而有 . 2. 证(1)n ?∈,有)2 ,2(12 ,12][-?-+-n n ,故 ∞ =-?-+-1)2 ,2(12 12][n n ,n . 另一方面,)2 ,2(-∈?x ,k ?∈ ,使][12 ,12k k x -+-∈,故 ∞ =-+-∈1 ][12 12n n ,n x ,于是 ? -)2 ,2( ∞ =-+-1 ][12 12n n ,n . 因此, ∞ =-+-= -1 ][12 ,12)2 ,2(n n n . (2)n ?∈,有)12 ,12(]2 ,2[n n +--?-,故 ∞ =+--?-1)12 ,12(]2 ,2[n n n . 另一方面,对任意]2 ,2[-?x ,即2>x ,k ?∈ ,使得212>+>k x ,即 )12 ,12(k k x +--?,从而 ∞ =+--?1)12 ,12(n n n x ,故 ∞ =-?+--1 ]2,2[)12 ,12(n n n .

数据库技术与应用(第二版)课后答案

第1章习题参考答案 1.思考题 (1)什么是数据库、数据库管理系统、数据库系统?它们之间有什么联系? 答:数据库是存贮在计算机的有结构的数据集合;数据库管理系统是一个软件,用以维护数据库、接受并完成用户对数据库的一切操作;数据库系统指由硬件设备、软件系统、专业领域的数据体和管理人员构成的一个运行系统。 (2)当前,主要有哪几种新型数据库系统?它们各有什么特点?用于什么领域,试举例说明?答:主要有:分布式数据库、面向对象数据库、多媒体数据库、数据仓库技术、空间数据库。 (3)什么是数据模型?目前数据库主要有哪几种数据模型?它们各有什么特点? 答:数据模型是一组描述数据库的概念。这些概念精确地描述数据、数据之间的关系、数据的语义和完整性约束。很多数据模型还包括一个操作集合。这些操作用来说明对数据库的存取和更新。数据模型应满足3方面要求:一是能真实地模拟现实世界;二是容易为人们理解;三是便于在计算机上实现。目前在数据库领域,常用的数据模型有:层次模型、网络模型、关系模型以及最近兴起的面向对象的模型。 (4)关系数据库中选择、投影、连接运算的含义是什么? 答: 1)选择运算:从关系中筛选出满足给定条件的元组(记录)。选择是从行的角度进行运算,选择出的记录是原关系的子集。 2)投影运算:从关系中指定若干个属性(字段)组成新的关系。投影是从列的角度进行运算,得到的新关系中的字段个数往往比原关系少。 3)连接运算:将两个关系按照给定的条件横向拼接成新的关系。连接过程是通过两个关系中公有的字段名进行的。 (5)关键字段的含义是什么?它的作用是什么? 答:一个关系中可以确定一个字段为关键字段,该字段的值在各条记录中不能有相同的值。(如:门牌);关键字段的作用主要是为建立多个表的关联和进行快速查询。 (6)什么是E-R图?E-R 图是由哪几种基本要素组成?这些要素如何表示? 答:E-R图也称实体-联系图(Entity Relationship Diagram),提供了表示实体类型、属性和联系的方法,用来描述现实世界的概念模型。构成E-R图的基本要素有3种,即实体、属性和联系。其表示方法为:用矩形框表示现实世界中的实体,用菱形框表示实体间的联系,用椭圆形框表示实体和联系的属性,实体名、属性名和联系名分别写在相应框。 ABAAC ABCAA 第2章习题解答 1. 思考题 (1)在SQL Server 2008中的数据库中包含哪些对象?其中什么对象是必不可少的?其作用又是什么? 答:SQL Server 2008中的数据库对象主要包括数据库关系图、表、视图、同义词、可编程性、Service Broker、存储和安全性等。其中表对象是必不可少的。表是由行和列构成的集合,用来存储数据。 (2)SQL Server提供的系统数据库master它的作用是什么?用户可以删除和修改吗?为什么?答:master 数据库记录SQL Server 系统的所有系统级信息。主要包括实例围的元数据、端点、服务器和系统配置设置以及记录了所有其他数据库的存在、数据库文件的

数据库系统概论(第四版)课后习题答案

第1章绪论习题参考答案 13.某工厂生产若干产品,每种产品由不同的零件组成,有的零件可用在不同的产品上。这些零件由不同的原材料制成,不同零件所用的材料可以相同。这些零件按所属的不同产品分别放在仓库中,原材料按照类别放在若干仓库中。请用E-R图画山此工厂产品,零件,材 第2章关系数据库习题参考答案 5.设有一个SPJ数据库,包括S,P,J,SPJ四个关系模式: 1)求供应工程J1零件的供应商号码SNO: πSno(σJno=‘J1’(SPJ)) 2)求供应工程J1零件P1的供应商号码SNO: πSno(σJno=‘J1’∧Pno=‘P1‘(SPJ)) 3)求供应工程J1零件为红色的供应商号码SNO: πSno(σPno=‘P1‘(σCOLOR=’红‘(P)∞SPJ)) 4)求没有使用天津供应商生产的红色零件的工程号JNO: πJno(SPJ)- πJNO(σcity=‘天津’∧Color=‘红‘(S∞SPJ∞P) 5)求至少用了供应商S1所供应的全部零件的工程号JNO: πJno,Pno(SPJ)÷πPno(σSno=‘S1‘(SPJ)) 第3章 SQL语言习题参考答案 用SQL语句建立第二章习题5中的四个表。 S(SNO,SNAME,STATUS,CITY); P(PNO,PNAME,COLOR,WEIGHT); J(JNO,JNAME,CITY); SPJ(SNO,PNO,JNO,QTY); 供应商表S由供应商代码(SNO)、供应商姓名(SNAME)、供应商状态(STATUS)、供应商所在城市(CITY)组成: CREATE TABLE S ( Sno CHAR(2) UNIQUE, Sname CHAR(6) , Status CHAR(2),

(完整版)数据库课后习题及答案

第一章数据库系统概述 选择题 1实体-联系模型中,属性是指(C) A.客观存在的事物 B.事物的具体描述 C.事物的某一特征 D.某一具体事件 2对于现实世界中事物的特征,在E-R模型中使用(A) A属性描述B关键字描述C二维表格描述D实体描述 3假设一个书店用这样一组属性描述图书(书号,书名,作者,出版社,出版日期),可以作为“键”的属性是(A) A书号B书名C作者D出版社 4一名作家与他所出版过的书籍之间的联系类型是(B) A一对一B一对多C多对多D都不是 5若无法确定哪个属性为某实体的键,则(A) A该实体没有键B必须增加一个属性作为该实体的键C取一个外关键字作为实体的键D该实体的所有属性构成键 填空题 1对于现实世界中事物的特征在E-R模型中使用属性进行描述 2确定属性的两条基本原则是不可分和无关联 3在描述实体集的所有属性中,可以唯一的标识每个实体的属性称为键 4实体集之间联系的三种类型分别是1:1 、1:n 、和m:n 5数据的完整性是指数据的正确性、有效性、相容性、和一致性 简答题 一、简述数据库的设计步骤 答:1需求分析:对需要使用数据库系统来进行管理的现实世界中对象的业务流程、业务规则和所涉及的数据进行调查、分析和研究,充分理解现实世界中的实际问题和需求。 分析的策略:自下而上——静态需求、自上而下——动态需求 2数据库概念设计:数据库概念设计是在需求分析的基础上,建立概念数据模型,用概念模型描述实际问题所涉及的数据及数据之间的联系。 3数据库逻辑设计:数据库逻辑设计是根据概念数据模型建立逻辑数据模型,逻辑数据模型是一种面向数据库系统的数据模型。 4数据库实现:依据关系模型,在数据库管理系统环境中建立数据库。 二、数据库的功能 答:1提供数据定义语言,允许使用者建立新的数据库并建立数据的逻辑结构 2提供数据查询语言 3提供数据操纵语言 4支持大量数据存储 5控制并发访问 三、数据库的特点 答:1数据结构化。2数据高度共享、低冗余度、易扩充3数据独立4数据由数据库管理系统统一管理和控制:(1)数据安全性(2)数据完整性(3)并发控制(4)数据库恢复 第二章关系模型和关系数据库 选择题 1把E-R模型转换为关系模型时,A实体(“一”方)和B实体(“多”方)之间一对多联系在关系模型中是通过(A)来实现的

MATLAB基础教程薛山第二版课后习题答案讲解

《及应用》实验指导书 《及应用》实验指导书 班级: T1243-7 姓名:柏元强 学号: 20120430724 总评成绩: 汽车工程学院 电测与汽车数字应用中心

目录 实验04051001 语言基础..................... 错误!未指定书签。实验04051002 科学计算及绘图............. 1错误!未指定书签。实验04051003 综合实例编程.. (31)

实验04051001 语言基础 1实验目的 1) 熟悉的运行环境 2) 掌握的矩阵和数组的运算 3) 掌握符号表达式的创建 4) 熟悉符号方程的求解 2实验内容 第二章 1. 创建的变量,并进行计算。 (1) 87,190,计算 、、a*b 。 (87); (190); *b (2) 创建 8 类型的变量,数值与(1)中相同,进行相同的计算。 8(87); 8(190); *b 2.计算: (1) 操作成绩 报告成绩

(2) e3 (3) (60) (3) (3*4) 3.设,,计算: (1) (2) (3) 23; (4*u*v)(v) (((u))^2)/(v^2) ((3*v))/(u*v) 4.计算如下表达式: (1) (2) (3-5*i)*(4+2*i) (2-8*i) 5.判断下面语句的运算结果。 (1) 4 < 20

(2) 4 <= 20 (3) 4 20 (4) 4 20 (5) 'b'<'B' 4 < 20 , 4 <= 20,4 20,4 20,'b'<'B' 6.设,,,,判断下面表达式的值。 (1) (2) (3) (4) (5) (6) 395837; a><>>> 7.编写脚本,计算上面第2题中的表达式。 ('(60)='); ((60)) ('(3)='); ((3)) ('(3*4)='); ((3*4)) 8.编写脚本,输出上面第6题中的表达式的值。395837;

《数据库系统概论》课后习题及参考答案

课后作业习题 《数据库系统概论》课程部分习题及参考答案 第一章绪论(教材 41页) 1.试述数据、数据库、数据库系统、数据库管理系统的概念。 数据: 描述事物的符号记录称为数据。数据的种类有文字、图形、图象、声音、正文等等。数据与其语义是不可分的。 数据库: 数据库是长期储存在计算机内、有组织的、可共享的数据集合。数据库中的数据按一定的数据模型组织、描述和储存,具有较小的冗余度、较高的数据独立性和易扩展性,并可为各种用户共享。 数据库系统: 数据库系统( DBS)是指在计算机系统中引入数据库后的系统构成。数据库系统由数据库、数据库管理系统(及其开发工具)、应用系统、数据库管理员构成。 数据库管理系统: 数据库管理系统 (DBMS)是位于用户与操作系统之间的一层数据管理软件。用于科学地组织和存储数据、高效地获取和维护数据。DBMS主要功能包括数据定义功能、数据操纵功能、数据库的运行管理功能、数据库的建立和维护功能。 2.使用数据库系统有什么好处? 使用数据库系统的好处是由数据库管理系统的特点或优点决定的。 使用数据库系统的好处很多,例如可以大大提高应用开发的效率,方便用户的使用,减轻数据库系统管理人员维护的负担等。 为什么有这些好处,可以结合第 5题来回答。

使用数据库系统可以大大提高应用开发的效率。因为在数据库系统中应用程序不必考虑数据的定义、存储和数据存取的具体路径,这些工作都由 DBMS来完成。 此外,当应用逻辑改变,数据的逻辑结构需要改变时,由于数据库系统提供了数据与程序之间的独立性。数据逻辑结构的改变是 DBA的责任,开发人员不必修改应用程序,或者只需要修改很少的应用程序。从而既简化了应用程序的编制,又大大减少了应用程序的维护和修改。 使用数据库系统可以减轻数据库系统管理人员维护系统的负担。因为 DBMS在数据库建立、运用和维护时对数据库进行统一的管理和控制,包括数据的完整性、安全性,多用户并发控制,故障恢复等等都由DBMS执行。 总之,使用数据库系统的优点是很多的,既便于数据的集中管理,控制数据冗余,可以提高数据的利用率和一致性,又有利于应用程序的开发和维护。 3.试述文件系统与数据库系统的区别和联系。 文件系统与数据库系统的区别: 文件系统面向某一应用程序,共享性差、冗余度大,独立性差,纪录内有结构、整体无结构,应用程序自己控制。 数据库系统面向现实世界,共享性高、冗余度小,具有高度的物理独立性和一定的逻辑独立性,整体结构化,用数据模型描述,由数据库管理系统提供数据安全性、完整性、并发控制和恢复能力。 文件系统与数据库系统的联系是: 文件系统与数据库系统都是计算机系统中管理数据的软件。 5.试述数据库系统的特点。 数据库系统的主要特点有: 一、数据结构化 数据库系统实现整体数据的结构化,这是数据库的主要特征之一,也是数据库系统与文件系统的本质区别。 二、数据的共享性高,冗余度低,易扩充

数据库原理课后习题答案.

第一章 1、试说明数据、数据库、数据库管理系统和数据库系统的概念以及它们之间的关系。 答:(1)数据(Data):描述事物的符号记录称为数据。数据的种类有数字、文字、图形、图像、声音、正文等。数据与其语义是不可分的。 (2)数据库(Database,简称DB):数据库是长期储存在计算机内的、有组织的、可共享的数据集合。数据库中的数据按一定的数据模型组织、描述和储存,具有较小的冗余度、较高的数据独立性和易扩展性,并可为各种用户共享。(3)数据库系统(Database System,简称DBS):数据库系统是指在计算机系统中引入数据库后的系统构成,一般由数据库、数据库管理系统(及其开发工具)、应用系统、数据库管理员构成。 (4)数据库管理系统(Database Management System,简称DBMS ):数据库管理系统是位于用户与操作系统之间的一层数据管理软件,用于科学地组织和存储数据、高效地获取和维护数据。DBMS的主要功能包括数据库的建立和维护功能、数据定义功能、数据组织存储和管理功能、数据操作功能、事务的管理和运行功能。 它们之间的联系:数据库系统包括数据库、数据库管理系统、应用系统、数据库管理员,所以数据库系统是个大的概念。数据库是长期存储在计算机内的有组织、可共享的大量的数据集合,数据库管理系统是由管理员操作管理数据库的查询、更新、删除等操作的,数据库应用系统是用来操作数据库的。 2、数据管理技术的发展主要经历了哪几个阶段? 答:两个阶段,文件管理和数据库管理。

3、比较用文件管理和用数据库管理数据的主要区别。 答:数据库系统与文件系统相比实际上是在应用程序和存储数据的数据库之间增加了一个系统软件,即数据库管理系统,使得以前在应用程序中由开发人员实现的很多繁琐的操作和功能,都可以由这个系统软件完成,这样应用程序不再需要关心数据的存储方式,而且数据的存储方式的变化也不再影响应用程序。而在文件系统中,应用程序和数据的存储是紧密相关的,数据的存储方式的任何变化都会影响到应用程序,因此不利于应用程序的维护。 4、数据库系统由哪几部分组成,每一部分在数据库系统中的作用大致是什么? 答:数据库系统由三个主要部分组成,即数据库、数据库管理系统和应用程序。数据库是数据的汇集,它以一定的组织形式存于存储介质上;数据库管理系统是管理数据库的系统软件,它可以实现数据库系统的各种功能;应用程序指以数据库数据为核心的应用程序。 第二章 1、解释数据模型的概念,为什么要将数据模型分成两个层次? 答:数据模型是对现实世界数据特征的抽象。数据模型一般要满足三个条件:第一是数据模型要能够比较真实地模拟现实世界;第二是数据模型要容易被

ml基础教程课后习题解答

X M L基础教程课后习 题解答 内部编号:(YUUT-TBBY-MMUT-URRUY-UOOY-DBUYI-0128)

XML基础教程课后习题 习题一 1.答:HTML是用来编写Web页的语言、不允许用户自定义标记,HTML体现数据的显示格式。XML描述数据的组织结构、可自定义标记,其标记名称是对标记所包含的数据内容含义的抽象,而不是数据的显示格式。 2.答:使用UTF-8保存 5.答:(1)不可以,(2)可以,(3)不可以 6.答:: time { display:block;font-size:18pt;font-weight:bold } hour { display:line;font-size:16pt;font-style:italic } mimute { display:line;font-size:9pt;font-weight:bold } 习题二1.答:(1)使用ANSI编码。(2)可以。(3)不合理。 2.答:不相同。 3.答:(1)和(2)。 4.答:。

5.答:“root”标记包含的文本内容都是空白字符。“a1”标记包含的文本内容:。“a2”标记包含的文本内容: 子曰"有朋自远方来,不亦乐乎"。 习题三1.答:一个规范的XML文件如果和某个DTD文件相关联,并遵守该DTD文件规定的约束条件,就称之为有效的XML文件。 2.答:DTD文件的编码必须和其约束的XML文件的编码相一致。 3.答:无关。 4.答:(1) 使用SYSTEM文档类型声明的格式: (2) 使用PUBLIC文档类型声明的格式: 5.答:一定。 6.答:(1)约束标记“张三”必须有“学号”属性 (2)约束标记“张三”必须有“学号”属性,而且学号的属性值是固定的220123。 (3)约束标记“张三”可以有也可以没有“学号”属性。 7.答:ID类型的属性的属性值具有互斥性,即所有ID类型的属性的属性值必须互不相同。 8.答:不合理。 9.答:(1)、(3)和(4)。 10.答,不是有效的。将修改为有效:

数据库原理及应用(第2版)习题参考答案..

第1章数据概述 一.选择题 1.下列关于数据库管理系统的说法,错误的是C A.数据库管理系统与操作系统有关,操作系统的类型决定了能够运行的数据库管理系统的类型 B.数据库管理系统对数据库文件的访问必须经过操作系统实现才能实现 C.数据库应用程序可以不经过数据库管理系统而直接读取数据库文件 D.数据库管理系统对用户隐藏了数据库文件的存放位置和文件名 2.下列关于用文件管理数据的说法,错误的是D A.用文件管理数据,难以提供应用程序对数据的独立性 B.当存储数据的文件名发生变化时,必须修改访问数据文件的应用程序 C.用文件存储数据的方式难以实现数据访问的安全控制 D.将相关的数据存储在一个文件中,有利于用户对数据进行分类,因此也可以加快用户操作数据的效率 3.下列说法中,不属于数据库管理系统特征的是C A.提供了应用程序和数据的独立性 B.所有的数据作为一个整体考虑,因此是相互关联的数据的集合 C.用户访问数据时,需要知道存储数据的文件的物理信息 D.能够保证数据库数据的可靠性,即使在存储数据的硬盘出现故障时,也能防止数据丢失 5.在数据库系统中,数据库管理系统和操作系统之间的关系是D A.相互调用 B.数据库管理系统调用操作系统 C.操作系统调用数据库管理系统 D.并发运行 6.数据库系统的物理独立性是指D A.不会因为数据的变化而影响应用程序 B.不会因为数据存储结构的变化而影响应用程序 C.不会因为数据存储策略的变化而影响数据的存储结构 D.不会因为数据逻辑结构的变化而影响应用程序 7.数据库管理系统是数据库系统的核心,它负责有效地组织、存储和管理数据,它位于用户和操作系统之间,属于A A.系统软件B.工具软件 C.应用软件D.数据软件 8.数据库系统是由若干部分组成的。下列不属于数据库系统组成部分的是B A.数据库B.操作系统 C.应用程序D.数据库管理系统 9.下列关于客户/服务器结构和文件服务器结构的描述,错误的是D A.客户/服务器结构将数据库存储在服务器端,文件服务器结构将数据存储在客户端 B.客户/服务器结构返回给客户端的是处理后的结果数据,文件服务器结构返回给客户端的是包含客户所需数据的文件 C.客户/服务器结构比文件服务器结构的网络开销小 D.客户/服务器结构可以提供数据共享功能,而用文件服务器结构存储的数据不能共享

数据库系统与应用课后习题答案

第二章关系数据模型 1.试述数据模型的概念、作用及三个要素。 答:数据模型是严格定义的一组概念的集合。这些概念精确地描述了系统的静态特征、动态特征和完整性约束条件。 数据模型的目的是为了表示数据并使数据容易理解,它是对现实世界数据特征的抽象。 一般地,一个数据库的基本数据模型至少必须包含以下三个组成部分:数据结构、数据操作和完整性约束。 1)数据结构 是指所研究的对象类型的集合。这些对象是数据库的组成成分。 2)数据操作 数据操作是指对数据库中各种对象的实例允许执行的操作集合,包括操作和有关的操作规则。 数据结构是对系统静态时特性的描述;数据操作时对系统动态特性的描述。 3)数据的完整性约束条件 数据的完整性约束条件是一组完整性规则的集合。完整性规则是给定的数据模型中数据及其联系所具有的制约和依存规则,用以限定符合数据模型的数据库状态以及状态的变化,以保证数据的正确、有效、相容。 2.试述各种数据模型的优缺点。 答:层次模型优点: 1)概念简单、层次清晰,易于理解; 2)数据库的安全性是由DBMS提供并保证的; 3)提供了良好的完整性支持。 4)数据独立,减少了程序编写和维护的工作量。 5)当数据库包含了大量具有1︰M联系的数据,并且用户所要求的大量事务使用联系固定的数据时,层次数据库模型效率非常高。 层次模型缺点: 1)在层次模型中,处理非层次性联系如多对多比较麻烦,只能通过引入冗余结点或虚拟结点来实现 2)缺乏结构独立性,查询子结点必须通过父结点; 3)实现复杂,难于管理。设计人员必须对数据的物理存储特性有非常深入的了解,另外系统对插入和删除有较多限制。 4)缺乏标准。 网状模型优点: 1)概念简单 2)对更多联系类型的处理。M:N 联系在网状数据库模型中比在层次数据模型中更易实现。 3)数据访问的灵活性。一个应用程序可以访问一个首记录和一个系中所有的属记录。 4)提高了数据库的完整性。网状数据库模型加强了数据库的完整性,因为用户必须首先定义首记录,然后才能定义属记录。 5)符合标准。网状数据模型基于由DBTG/CODASYL提出和ANSI.SPARC扩展的通用标准。 6)数据独立。网状数据模型获得了足够的数据独立性,至少在一定程度上将程序从

数据库课后习题参考答案

数据库课后习题参考答案

第1章数据库基础 习题答案 1. 简述Oracle 12c的应用结构。 答:参阅教材 2. 简述Oracle与SQL Server的区别。 答:参阅教材 3. 简述Oracle 12c的新特性。 答:参阅教材 第2章Oracle Database 12c的安装和配置习题答案 一、填空题 1. Windows Unix 2. 1GB 3. 物理内存的两倍 4. orcl 5. 5500 6. SYSDBA Normal 第3章Oracle Database的体系结构 2

习题答案 一、选择题 A B B D B C D D 二、简答题 1.什么是Oracle的实例?它是一种什么机制? 答:Oracle数据库系统指具有管理Oracle数据库功能的计算机系统。每一个运行的Oracle 数据库都对应一个Oracle实例(Instance),一个Oracle实例为存取和控制数据库的软件机制。当数据库服务器上的一个数据库启动时,Oracle将分配一块内存区间,叫做系统全局区(SGA),并启动一个或多个Oracle进程。因此实例是一组内存结构和后台进程的集合。总之,Oracle实例是指数据库拥有自己的系统全局区和相关数据库文件的Oracle服务器进程集,是存取和控制数据库的软件机制。 2.段是什么概念?如何组成的? 答:表空间的下一级逻辑存储单位称作段,一个段只能存储同一模式对象。根据存储模式 -3-

4

责将需要处理的数据从数据库文件读入到SGA中的数据库缓冲区,并将SQL语句执行的结果返回给客户端应用程序。 后台进程:系统为了使性能最好和协调多个用户,在多进程系统中使用一些附加进程,称为后台进程。 用户进程:用户进程指运行应用程序或Oracle工具所建立的进程,它们向Oracle服务器发送所要执行的SQL语句 第4章数据库操作 习题答案 一、选择题 B C B C 二、选择题 1. CREATE DATABASE 2. SHUTDOWN IMMEDIATE 3. DROP DATABASE 4. 启动实例装载数据库打开数据库 5. STARTUP FORCE 5

大学计算机基础教程课后习题答案.doc

第一章 1.1946 2.大规模集成电路 3.计算机辅助设计、计算机辅助教学、计算机辅助制造、计算机辅助测试、计算机辅助教育、操作系统 4.人工智能 5.存储程序工作原理 6.运算器 7.RAM 8.逻辑 9.字长 10.位、字节 11.位、字节 12.1024、1024、1024*1024 13.1 14.2 15.48H、65H、97H、32 16.288 17.操作系统 18.程序 19.高级语言 20.机器 21.编译、解释 22.应用、系统 23.输入、输出设备 24 .硬盘 25.高速缓冲存储器 26.传染性 27.2 28.R (文科不做) 29.111111 K 7f (文科不做) 30.213、D5 (文科不做) 第二章 1.255 2.隐藏 3.存档 4.内存条、硬盘 5.Alt

6.[cttl+shift]> [shift+o] [ctrl+space] [ctrl+o] 7.[alt+F4] 8.后台 9.[Shift]> [Ctrl] 10.[Shift] 11.[Ctrl] 12.回收站 13.msconfig 14.单击该按钮会弹出对话框、有下级了菜单、当前状态不可用 15.[Ctrl+Esc]或[win ] 16.最大化或还原 17.分辨率 18.刷新频率 19.磁盘清理 20.[Ctrl+Shift+Delete] 第三章 1.doc 2.我的文档 3.拼写错误、语法错误 4.一行、一段、全部 5.页面 6.回车符号 7.[Alt+Tab] 8.[Ctrl+O] 9.[Ctrl+N] 10.页眉页脚 第四章 1.3、255 2.65536、256 3.[Ctrl+; ]> [Ctrl+Shift+;] 4.= 5.40833 6. 3 7.[ Ctrl ] 8.$ 9.地址栏 10.F2 第五章

相关主题