关系数据库试题(英文版以及答案)

合集下载

数据库试题答案 英文卷

数据库试题答案 英文卷

哈尔滨理工大学 2006-2007学年第一学期考试试题答案 A 卷 考试科目: 数据库系统 考试时间:120分钟 试卷总分100分 考试班级: 题号 一 二 三 四 五 六 七 八 九 十 总分 得分 评卷教师 I 、Choice Questions 1.B 2.C 3.D 4.B 5.D 6.C 7.D 8.D 9.B 10.C II 、 B lank-filling Questions. 1、① condition(s) , ② action(s) 2、A= 180 ;B= 170 3、① logical , ② view or ① view ,② logical 4、 4ms 5、① optimizer ② evaluation engine III 、 A nswer the following questions briefly. 1、 A superkey is a set of one or more attributes that, taken collectively, to identify uniquely an entity in the entity set. Candidate keys are minimal superkeys which no proper subset is a superkey. Primary key is a candidate key that is chosen as the principal means of identifying entities within an entity set. 2、 Database administrator's duties include: (choose any four from the following) ● Schema definition ● Storage structure and access method definition ● Schema and physical organization modification● Granting user authority to access the database● Specifying integrity constraints● Acting as liaison with users● Monitoring performance and responding to changes in requirements3、 a) U2, U3 and U5;b) U1, U3, U4 and U5.4、 result = ADresult = ABCD (A → C and A → B)result = ABCDE (CD → E and CD ⊆ ADBC)result = ABCDEH (CD → H and CD ⊆ ADBCE)Is AD a candidate key?1. Is AD a super key?1 Does AD → R? == Is (AD)+ ⊇ R装订线 班级: 学号:姓名:2.Is any subset of AD a superkey?1Does A→R? == Is (A)+ ⊇ R2Does D→R? == Is (D)+ ⊇ R??5、The relation schema SCT is not in BCNF. After decomposition the relation schemas are:IV、Complete the following queries.1. a) ∏customer_name (borrower) ⋃∏customer_name (depositor)b) account ←account –σbranch_name = “Perryridge” (account )c) account ←account ⋃{(“Perryridge”, A-973, 1200)}depositor ←depositor ⋃{(“Smith”, A-973)}2. create table account( account_number char(10),branch_name char(15),balance numeric(12,2),primary key (account_number),foreign key (branch_name) references branch,check (balance >=0))3. a) select loan_numberfrom loanwhere branch_name = … Perryridge‟ and amount > 1200b) (select customer_name from depositor)intersect(select customer_name from borrower)c) select branch_name, avg (balance)from accountgroup by branch_namehaving avg (balance) > 1200d) select loan_numberfrom loanwhere amount is null哈尔滨理工大学2006-2007学年第一学期考试试题答案A卷V、Resolve the following questions of designing.1、E-R diagram for the university registrar‟s office:2、The relational database corresponding to the preceding E-R diagram:student( sid, name, program)course_offering(courseno, secno, year, semester, time, room)Instructor(iid, name, department,title)courses(courseno, title, credits, syllabus)enrolls(sid, secno, grade)teaches( iid, secno)requires(couseno, prerequisite, maincourse)。

数据库试卷英文版

数据库试卷英文版

Database System Principle Final Examination Name:___________ Student ID:__________Scores:________Exam Rules:1) Close book and notes, 100 minutes2) Please write down your name and student ID number NOW.3) If you think a problem is ambiguous, write down your assumptions, argue that they arereasonable, then work on the problem using those assumptions.4) Please write your solutions in the spaces provided on the exam. Make sure yoursolutions are neat and clearly marked. You may use the blank areas and backs of the exam pages for scratch work. Please do not use any additional scratch paper.1. (15 points) ER and Translation to Relational Model:a. [10 points] Create a relational schema that captures this E/R diagram. For everyrelation in your schema, specify the key of that relation.b. [5 points] What is the key for entity " Contract_Emps "? And what is the key for2. (10 points) Schema Refinement:Consider the relation R(A,B,C,D,E) with the following functional dependencies: (A, B)->E, (C, D)->E, A->C, C->A.Is R in BCNF? If not, decompose R into a collection of BCNF relations. Show each step of the decomposition process.3. (20 points, 5 points each) Relational Algebra and SQL Queries: Consider a database schema with the following relations:Student (ssn, name)Prof (ssn, name)Course (number, instructor-ssn, title, credits, room#)Enroll (student-ssn, course#)Room (number, capacity)a.Write a relational algebra query that finds the names of all students who areenrolled in a class taught by “Jones”.b.Write an SQL query that finds the names of all students who are NOT enrolled intwo classes held in the same room.c.Write an SQL query that lists, in alphabetical order(按字母顺序), the title of allcourses either taught by “Smith” OR are taught in room number 444. Do not list duplicate titles.d. Write an SQL query that considers all the courses that have ever been taught by“Brown” and are of 3 credits, and groups them according to title. For each course, the query should compute the average capacity of rooms in which the course has been offered, then return only courses for which this average is more than 20.(请在横线上填入合适表达式完成该查询)SELECT Course.title, AVG (Room.capacity)FROM Prof, Course, RoomWHERE____________________________________________________________________________________________________________________GROUP BY _________________________________________________HAVING__________________________________________________4. (16 points) Transaction ManagementConsider the following sequence of log records:<START S>; <S,A,60,61>;<COMMIT S>; <START T>; <T,A,61,62>; <START U>;<U,B,20,21>; <START CKPT (T,U)>; <T,C,30,31>; <START V>; <U,D,40,41>;<V,F,70,71>; <COMMIT U>;<END CKPT>; <T,E,50,51>; <COMMIT T>;<V,B,21,22>; <COMMIT V>.if there is a crash and the last log record to appear on disk is:a) <T,E,50,51>b) <COMMIT T>a)当日志中的最后一条记录为<T,E,50,51>时,利用日志对数据库进行恢复后,恢复后的下列值应为多少?A is set to ______B is set to ______C is set to ______D is set to ______E is set to ______F is set to ______此时恢复数据库完成后,应在日志文件中填入什么记录?Write ______________and _______________ records on the log.b)当日志中的最后一条记录为<COMMIT T>时,利用日志对数据库进行恢复后,恢复后的下列值应为多少?A is set to ______B is set to ______C is set to ______D is set to ______E is set to ______F is set to ______5.(9 points)Consider the following schedule involving three transactions T1, T2 and T3:a)Draw the precedence graph for this schedule.b)Is this schedule conflict serializable? Why or why not? If it is conflict serializable,give the equivalent serial schedule (just write the order of the transactions).6.(30 points)选择题,请将答案写在下面表格里。

数据库原理基础教程英文版答案CH1 作业(1)

数据库原理基础教程英文版答案CH1 作业(1)

CH1 作业Fill in the blank.1、A data model is a notation for describing data or information. The description generally consists of three parts: 、、.2、and is called the schema for that relation.3、When clearing key (keys), an attribute or list of attributes may be declared or .4、If PRIMARY KEY is used, then attributes in S are not allowed to have as a value for their components.True or false1、The relational model is based on tables.2、SQL value can’t be NULL.3、Either says that no two tuples of the relation may agree in all the attribute(s) on the list.4、No attribute of a PRIMARY KEY can ever be NULL in any tuple. But attributes declared UNIQUE may have NULL’s, and there may be several tuples with NULL.5、Like HTML, the opening tag in XML can have atttribute = value pairs.Single choice.1、In the following figure, there are instances of two relations that might constitute part of abanking database. Indicate the following:The attributes of Account relation is.A.acctNo, type, balance B. acctNo, type C. acctNo, balance D. acctNom, type, balance2、How many different ways (considering orders of tuples and attributes) are there to represent a relation instance if that instance has:n attributes and m tuples?A. n!m!,B. (n-1)!m!,C. n!(m-1)!, D n!(m+1)!3、How many different ways (considering orders of tuples and attributes) are there to represent a relation instance if that instance has:Four attributes and five tuples?A.1440,B. 2880,C.576, D 7204、How many different ways (considering orders of tuples and attributes) are there to represent a relation instance if that instance has:Three attributes and three tuples?A. 20,B. 25,C.36, D 48Multiple choice1、In the following figure, there are instances of two relations that might constitute part of abanking database. Indicate the following:The tuples of Account relation are.A. (12345, savings, 12000)B. (34567, checking, 1000),C. (23456, checking, 1000)D. (34567, savings, 25)Essay question1、We suggested that there are many examples of attributes that are created for the purpose of serving as keys of relations. Give some examples.。

数据库原理(双语)习题assignment - of - module02

数据库原理(双语)习题assignment - of - module02

数据库原理(双语)习题assignment - of - module02Assignment of Module02Questions:2.1 Discuss each of the following concepts in the context of therelational data model: (a) relation (b) domain (c) attribute (d) tuple(e) degree and cardinality2.2 Discuss the properties of a relation2.3 Discuss the difference between the candidate keys and the primary key of a relation. Example what is meant by a foreign key. How do foreign keys of relations relate to primary key? Give examples to illustrate your answer. (1)Candidate Key (2)Primary Key (3) Foreign Keys2.4 Define the two principal integrity rules for the relational model. Discuss why it is desirable to enforce these rules.2.5 What is view? Discuss the difference between a view and a base relation.Exercises :The following tables form part of a database held in a relational DBMS: Hotel (hoteNo, hoteName, city) Room (roomNo, hoteNo, type, price)Booking (hoteNo, guestNo, dateFrom, dataTo, roomNo) Guest (guestNo, guestName, guestAddress)Where Hotel contains hotel details and hotelNo is the primary keys;Room contains room details for each hotel and (roomNo, hoteNo) forms the primary key;Booking contains details of bookings and (hoteNo, guestNo, dateFrom) forms the primary key; Guest contains guest details and guestNo is the primary key.2.6 Identify the foreign keys in this schema. Explain how the entity and referential integrity rules apply to these relations.2.7 describe the relations that would be produced by the following relational algebra operations: a) ∏hotelNo(? price>50(Hotel))b) ? Hotel.hotelNo=Room.hotelNo(Hotel × Room)c) ∏hotelNo(Hotel∞Hotel.hotelNo=Room.hotelNo(? price>50(Room)))d) (? dataeTo≥’1-Jan-2002’(Booking))∝Gueste) Hotel�SHotel.hotelNo=Room.hotelNo(? price>50(Room)) (‘�S’meanssemi-join operation) f) (∏guestNo,hotelNo (Booking∞(Guest)))÷∏hotelNo(? city=’London’Hotel))2.8(a) List full details of all hotels.(b) List all single rooms with a price below $20 per night. (c) List the names and cities of all guests.(d) List the price and type of all rooms at the Grosvenor Hotel. (e) List the guests currently staying at the Grosvenor Hotel.(f) List the details of all rooms at the Grosvenor Hotel, including the name of the guest staying in the room, if the room is occupied(g) List the guest details(guestNo, guestName, and guestAddress) of all guests staying at Grosvenor Hotel.2.9 Using relational algebra, create a view of all rooms in the Grosvenor Hotel, excluding price detail. What are the advantage of this view?2.10 Represent, by means of one or more relations, the information contained in a timetable of departures from a railway station. Show the number, time, final destination, category and stops of every departing train.感谢您的阅读,祝您生活愉快。

数据库英语综合测试题16

数据库英语综合测试题16

数据库英语综合测试题16Part 3: Questions and Answers1.Consider the following relational schema:student (student no, _rst name, last name)book (isbn, title, authors, publisher, year)loan (student no, isbn, checkout date, duration)Use SQL to write the following queries:A. Create the table for the book table appropriate domain and required contraints.B. Change the data type of the checkout date attribute of the loan table to date.C. Add a constraint into the loan table to make sure the loan duration is no more than 180 days.D. Grant Arvil and Amy select and update authrorization on the book table.2.What are 6 basic operators of relational algebra?3.Explain how natural-join operation can be accomplished by basicrelational algebra operations?4.Explain how the division operation can be accomplished by basicrelational algebra operations?5.The database of a research center contains the following three tablesabout employees,projects, and the time spent by the employees on theprojects.Employee(ssn: int, name: string, jobTitle: string)Project(pid: int, name: string, sponsor: string, startYear: int, endYear: int) WorkedOn(ssn: int, pid: int, year: int, month: int, noHours: int).The table Employee lists all the employees of the centre. The table Project lists all the projects of the centre with their sponsor and the start and end year of the project. The table WorkedOn records how many hours the employees have spent on which project in which month. For each table, the attributes that make up the primary key are underlined.Express each of the following queries in relational algebra.A. Return the names of the projects that were active in 2008.B. Return the names of those programmers who in some month spent more than60 hours on a project sponsored by the EU.C.Return the names of those programmers who never worked on a project sponsored by the EU.6.Consider the relational schema of Question 5. Write SQL queries overthis schema that answer the following questions.A. How many projects that were active in 2008 were sponsored by the EU?B. For each project, year, and month, how many hours of work have been spent? (Return only data for a project, year and month if some time has been spent.)C. How many programmers are there who have experience in working on a project sponsored by the EU? (Note that a programmer who worked on two or more projects should be counted only once.)D. Return the names of the programmers who worked on no more than two projects sponsored by the EU. (Note that this includes the programmers whonever worked on any project sponsored by the EU.)E. Which programmer(s) spent the maximal total number of hours on EU projects among all programmers working on EU projects?7.Consider the following relation that keeps track of the bookings in ahotel:Booking(guestID, guestName, creditCard, roomNo, roomCat, from, to). Suppose the following functional dependencies hold on the relation:guestID → guestName, creditCardroomNo → roomCatroomNo, from → guestID, toroomNo, to → guestID, from.A. Decompose the relation in smaller relations such that– each of the smaller relations is in BNCF with respect to the projection of the original dependencies;– the decomposition is a lossless join decomposition.B.Is your decomposition dependency preserving? If your answer is “yes”, argue why. If your answer is “no”, show which dependencies have been lost.8.Draw an ER diagram that captures all the following information:_ Patients are identified by an SSN, and their names, addresses and ages must be recorded._ Doctors are identified by an SSN. For each doctor, the name, specialty and years of experience must be recorded._ Each pharmacy has a name, address and phone number. A pharmacy must have a manager._ A pharmacist is identified by an SSN, he/she can only work for one pharmacy. For eachpharmacist, the name, qualification must be recorded._ For each drug, the trade name and formula must be recorded._ Every patient has a primary physician. Every doctor has at least one patient. _ Each pharmacy sells several drugs, and has a price for each. A drug could be sold at several pharmacies, and the price could vary from one pharmacy to another._ Doctors prescribe drugs for patients. A doctor could prescribe one or more drugs for several patients, and a patient could obtain prescriptions from several doctors. Each prescription has a date and quantity associated with it.9.Convert the following E/R design (for a simple banking application) intoa relational design. Give the relational design as a relational diagramwith arrows to indicate the foreign key relationships. Underline allattributes that correspond to primary keys.10.Consider the following employee database, where the primary keys areunderlined.Employee(ename:string, street:string, city:string);Works(employee:string, company:string, salary:real);Company(cname:string, city:string);Manages(employee:string, manager-name:string)Give a single SQL statement for each of the following queries:A. Find the names, street addresses, and cities of residence of all employees who work for “First Bank Corporation" and earn more than $40,000.B. Find the names of all employees in the database who live in the same cities as the companies for which they work.C. Give all managers of \First Bank Corporation" a 10 percent salary raise.D. Find the names of all employees in the database who earn more than any employee of “Small Bank Corporation".E. Assume that the companies may be located in several cities. Find the names of all companies located in every city in which \Small Bank Corporation" is located.F. Find the name of the company that has the most employees.G. Find those companies whose employees earn a higher salary, on average, than the average salary at “First Bank Corporation", display those companies' names in ascending order.11.Consider the following (simplified) relational schema for universitystudy:Student(id:integer, family:string, given:string, degree:string, enrolled:date) Course(id:integer, code:string, session:string, title:string, syllabus:string) Enrolment(student:integer, course:string , mark:real, grade:string)A.For each of the following SQL queries, write an efficient relational algebra expression that might be used to implement the query. To make the expressions clearer, you may use as many named intermediate temporary relations as you wish. Correct, but grossly inefficient, relational algebra expressions will be awarded only half marks.A. select given,family from StudentB. select * from Enrolment where student=2233456C. select given,family,coursefrom Enrolment, StudentD.from Enrolment e, Course c, Student swhere e.course = c.id and e.student = s.id and s.id = 223456712.Consider the following E/R diagram, modeling data about patients in ahospital:A. Perform a conversion of the E/R diagram into relation schemas. You should eliminate relations that are not necessary (e.g., by combining relations).13.Given the interleaved schedules:Schedule 1T1 RA. RC. WC. CommitT2 RC. WC. RB. WB. CommitT3 RC. RA. WA. CommiSchedule 3A. Which of the following schedules are serializable? Give a serial schedule or identify possible anomalies.B. Draw the precedence graph for all three schedules and check whether they are conflict-serializable or not.C. Apply strict 2PL to the non-conflict-serializable schedulesD. In one of the schedules a deadlock emerges – draw the waits-for-graph for this schedule after all transactions are captured in the deadlock situation. (Use X(.) to denote exclusive locks and S(.) to denote shared locks!)14. Consider a relational schema ABCDEFGHIJ, which contains thefollowing FDs:AB →C, D →E, AE →G, GD →H, IF →J.A. Check whether or not the functional dependencies entail ABD →GH ABD →HJ ABC →G GD →HEB. Let A denote a key for the aforementioned relation. Derive a lossless join,dependency preserving decomposition in 3NF!15. What do the ACID properties stand for? Give a brief description of thefour characteristics.16. What are the serial schedule, equivalent schedules and serializabletT1 RA. RC. WA. Commi tT2RC. RB. WB. Commi tT3 RB .WB. CommitT1 RC. WA. WA. Commit T2 WA. RB. WB. Commitschedule?17.Let R and S are two relations shown as below:RA B C1 2 34 5 67 8 9SB C D2 3 102 3 116 7 12Write the results of the following queries:A. ∏A,B+C→ X(R)B. ∏B,C(R) -∏B,C(S)C. BϑB,sumD.(S)D. BϑB,maxD.(R S)18.Consider the following relational schema for movie DVD rental store: customer (customer id, first name, last name)DVD (dvd id, title, genre, director, released year)borrow (customer id, dvd id, checkout date, duration)Use SQL to write the following queries:A. Create 3 tables for the above schema with appropriate domain and required contraints.B. Change the data type of the checkout date attribute of the borrow table to date.19.Consider the following gradebook relational schema describing the datafor a grade book of a particular instructorcatalog(cno, ctitle)students(sid, fname, lname, minit)courses(term, secno, cno, score)enrolls(sid, term, secno)Use relation algebra and SQL to write the following queries:A. Retrieve the names of students enrolled in the 'Database' class in the term of Fall 2009.B. Retrieve the names of students who have enrolled in CS226 or CS227.C. Retrieve the names of students who have not enrolled in any class.D. Retrieve the titles of courses whose average score of the whole class is more than 80.20.Consider a company database with the following relation schemas whereprimary keys are underlined:employee (first name, last name, id no, birthday, gender, salary, supervisor id no, department no)department (department name, department no, manager id no)department locations (department no, department location)project (project name, project no, project location, department no)works on (id no, project no, hours)Use relation algebra and SQL to write the following queries:A. Retrieve the names of all employees in the 'Research' department who work more than 10 hours per week on the 'ProductX' project.B. Find the names of employees who are directly supervised by 'Avril Lavigne'.C. Retrieve the names of employees who work on every project.D. Retrieve the names of all employees who work on at least one project located in Houston but whose department has no location in Houston.E. For each department, retrieve the department name, number of employees in that department, and the average salary of employees working in that department.F. For each department whose average employee salary is more than $50000, retrieve the department name andthe number of employees working for that department.G. Remove employees whose salary is more than $100000.H. Increase the pay of all employees in the 'Research' department by 5%21.Consider the following bank schema.account (account id, branch name, balance)borrower (customer id, loan number)branch (branch id, branch name, branch city, assets)customer (customer id, customer name, customer street, customer city) depositor (customer id, account number)loan (loan number, branch id, amount)Write SQL commands for the following query:A. Retrieve all different branch names.B. Retrieve all loan number that falls between 1000000 and 2000000.C. Retrieve all customer names in the ’East Gate’ branch.D. Retrieve the branch name and number of accounts for each branch.22.Consider the following order table.orderno date customernocustomernameitemproduct noproductname unitunitpriceamount price06102 48 2006-5-30VICRPVictorCorp.110001042rice3Kg/bag150 10 150006102 48 2006-5-30VICRPVictorCorp.210001072coke24cans/box480 5 240006102 49 2006-6-8DONDIDondiCorp.110001014milk24bottles600 9 5400where the keys are underlined.A. Normalize the above table to the 3 NF and draw the relational schema diagram and indicate the primary keys and the referential constraints.B. Based on the above schema diagram draw the ER diagram.23. A student relation has 4 attributes: student id, name, email, and phoneno. No two customers have the same student id and email.A. List keys, superkeys, and primary key for the student relation.B. Explain the reason of choosing the primary key.24. Consider the following electronic store database:Use SQL to answer the following questions.A. Create the product table with the required constraints.B. Add a constraint of price > 0 in the product table.C. Insert ('P2348', 'Personal Computer', 1200) into the product table.D. Find the all customers who have ordered a WII.E. Change the price of 'WII' from 8000 to 7500.F. Remove all orders that 'Lady Gaga" has put.0610249 2006-6-8 DON DI Dondi Corp. 2 10001051 corn chips 24bags/box 720 53600 06102492006-6-15 JENR E Jenren Corp. 1 10001002 beer 24cans/box 480 104800customer table customer id name C98022Lady Gaga C98145Lily Allen C98262Taylor Swift purchase table customer id order noC98022 O1234 C98145 O2234 C98262 O1681 order table order no product no O1234 P1168 O2234 P1234 O1681 P1688 product table product no product name pric e P1168 MP3 Player 1200 P1234 WII 8000 P1688DVD Player 300025.Consider The database of a online game company has three relations:player, play, and game for storing information about players who playswhich game. The database schema of the game company is shown asfollows:player (member no, name, level, phone, email)play (member no, game id, date, time)game (game id, title, type)Please draw the ER diagram.26.Consider a HollyWood Enterprise that requires modeling informationabout the different type of peopleA.involved in the movie production.B._ Each person should have person ID, name, phone, gender, and address.C._ There are two main groups of persons: Movie professionals andcelebrity. Each movie professionals work on somepany.E._ A movie professionals can be either a director or a agent. Each directorhas her or his popularity and can direct aF.number of movies. Each agent has the agent fee.G. A celebrity can be a movie star, a model, or both. Each movie star hasher or his movie style and play in someH.movies. Each model has her or his preferences.I._ Each movie has the information about the title, released date, andlanguage.J.Draw a EER diagram for the above HollyWood Enterprise.K.The owner of several apartment buildings is interested in a database to manage hisL.business.M.Buildings have one or more apartments. Every building has an address.N.Apartments have apt. nos., and are characterized by their size: 1BR, 2BR, etc.O.Tenants lease apartments. Each lease has a lease date and a period of lease.P.Tenant information is his/her name and phone number.Q.Each building has a manager. The manager has a name, telephone no. and salary.R.Each building has some parking spaces. Some tenants rent the parking spaces.Design an E-R diagram for the above. State any additional assumptions.Convert the above E-R diagram (Q.1) to relational model and write the SQL commands to create the tables for both the entities as well as relationships.27.The following questions are based on a Sporting Goods databasedescribed below:customer (id: int, name: string, city: string, country: string, rating: string, sales_rep_id: int )dept(id: int, name: string, region_id: string)sales_rep(id: int, last_name: string, first_name: string, dept_id: int, salary: int)order(id: int, customer_id: int, date_ordered: date, total: int)Write SQL queries for each of the following sub-questions.A. Display the name, city, country and rating of all customers whose number oforders exceeds the “average” number of orders for a customer.B. Display the name of all the departments that have at least one employee.C. Display the first name and last name of all sales representatives who donot have customers.D. Find the countries in which there are no sales representatives. If required, make any assumptions and state them.28.Consider the relation R, which has attributes that hold schedules ofcourses and sections at a university; R = {CourseNo, SecNo,OfferingDept, CreditHours, CourseLevel, InstructorSSN, Semester, Year, Days_Hours, RoomNo, NoOfStudents}. Suppose that the followingfunctional dependencies hold on R:{CourseNo} →{OfferingDept, CreditHours, CourseLevel} {CourseNo, SecNo, Semester, Year} →{Days_Hours, RoomNo, NoOfStudents, InstructorSSN}{RoomNo, Days_Hours, Semester, Year} →{InstructorSSN, CourseNo, SecNo}A.Try to determine which sets of attributes form keys of R. How would younormalize this relation?29.Consider the relational database schema and write the SQL statementsaccording to the this model.Part(PartNo, PartName, ProjNo Price, Weight)Project(ProjNo, ProjName, Location, departNo)Emp(Ssn, Name, Surname, departNo, Addres, salary)Work(ssn, ProjNo, Hour)A.Listing the workers info, according to the PartNo=24 that is used in theone project.B.Listing the project names and locations, according to the employeesaddress includes “Bahcesehir”.C.Alter the emp table and add a new column which is corresponding theemp’s birth date.D.List the emp info, according to the his salaries greater than avaragesalary of the emp table.30.Branch(branch-name, branch-city, assets)Account(account-number, branch-name,balance)Depositer(customer-name, account-number)Customer(customer-name, customer-street, customer-city)Loan(loan-number, branch-name, amount)Borrower(customer-name, loan-number)Database schema is given above.A.Find all customers who have both an account and a loan in the bank.B.Find all customers who have a loan at the bank but do not have anaccount at the bank.C.Find all customers who have both an account and a loan at thePerryridge branch.D.Find all branches that have greater assets than some branches locatedin Brooklyn.E.Find all loan numbers which appear in the loan relation with nullvalues for amount.31.You have been asked to design a database for the universityadministration, which records the following information:1. All students necessarily have a unique student ID, a name, and a university email address. Each student is also either an undergraduate or a graduate student.2. Each graduate student has an advisor.3. Each undergraduate student has a major.4. Students take courses. A student may take one course, multiple courses, or no courses.5. Each course has a course number, course name, and days of the week the course is scheduled.6. Each course has exactly one head TA, who is a graduate student.7. Every head TA has an office where he or she holds office hours.A. Draw an ER diagram for this application. Be sure to mark the multiplicity of each relationship of the diagram. Decide the key attributes and identify them on the diagram. Please state all assumptions you make in your answers.B. Translate your ER diagram into a relational schema. Select approaches that yield the fewest number of relations; merge relations where appropriate. Specify the key of each relation in your schema.32.Consider a relation R with five attributes A, B, C, D, and E. Thefollowing dependencies are given:AB→ C, BC → D, CD → E, DE → A.A. List all keys for R. Do not list superkeys that are not a key.B. Is R in 3NF? Briefly explain why.C. Is R in BCNF? If yes, please explain why. Otherwise, decompose R into relations that are in BCNF.33.The following questions refer to the database schema below: Product(pid,price, color), Order(cid, pid, quantity), Customer(cid, name, age).A. Write a query, in relational algebra, to return the names of customers who order at least one product with color “Red.”B. Write an SQL query, to return the total quantity of products ordered by customers with age greater than 70.C. Write an SQL query, to return the pid(s) of the most ordered product(s) (i.e. the product(s) with the highest total ordered quantities).34.Consider “drinker” database with the following relations.Drinker(drinkerName, street, age)Bar(barName, owner, street)Frequent(drinkerName, barName)We ask you to write queries. Please write simple and non-redundant queries –Note that we will really check if your answers are unnecessarily complex.A. In relational algebra, write a query to return the bars that Sally frequents.B. In relational algebra, write a query to return each drinker who frequents only bars on the same street that he lives.C. In SQL, write a query to return the bars whose frequent drinkers are “young”– in particular, with average age below 37.35.Consider the following relational schema:Account(accountNumber, branchName, balance)Branch(branchName, street, city, assets)Customer(customerSSN, street, city)Deposit(customerSSN, accountNumber,Amount)A. List all the attributes (in the four tables) that are foreign keys and indicate what attributes they are referencing.B. Define a view BigBranch that gives for each branch its branchName, city, and assets. The branch should have more than 50 accounts and the total balance of all accounts is greater than $1,000,000.C. Suppose we want to check that, for each branch, the total balance of all accounts is less than or equal to the assets of the branch. Complete the following SQL statement, by specifying _condition_. Note, by definition, such an “assertion” statement will enforce the _condition_ to hold true at all times. CREATE ASSERTION BalanceCheck CHECK _condition_36. Convert the following unnormalized tables into First Normal Form (1NF)relations :(a) R(A, B, {C, D})(b) R(A, B, {C, D, {E, F}})37. Convert ER diagrams A and B below into relations.EMPLOYEE supervisesEMP#Name 1NSkillsSUPPLIER BRANCHsuppliesS#SName B#BName M N BLocationDateSLocation A B。

数据库考试题及答案

数据库考试题及答案

习题一、[12分] 用英文解释1、DBMS2、Data Dictionary3、Transaction[10分]二、单项选择题1.There may be instances where an attribute has a set of values for a specific entity. This type of attribute is said to be 【】A.single valued attribute B.multivalued attributeC.simple attribute D.composite attribute2.In a particular bank, a loan can belong to only one customer, and a customer can have several loans, then the relationship set from c ustomer to loan is【】A.one to many B.many to many C.many to one D.one to one3.A【】contains metadata─ that is, data about data.A.table B.view C.data dictionary D.trigger【】4.The phrase “greater than at least one” is represented in SQL byA.>all B.<all C.<some D.>some5.In general, all aggregate functions except 【】ignore null values in their input collection.A.sum B.avg C.min D.countby a series of swaps of non-conflicting 6.If a schedule S can be transformed into a schedule S’ e【】instructions, we say that S and S’ arA.non-conflicting equivalent B.conflict equivalentC.non-conflicting serializable D.conflict serializable7.The fundamental operations in the relational algebra are【】。

数据库试题-英文卷

数据库试题-英文卷

考试科目: 数据库系统 考试时间:120分钟 试卷总分100分题号I II III IV V 总分 得分 评卷教师I 、Choice questions. (Write your answers onto the answer sheet.)(There are 10questions, totally 20 marks, and each question worth 2 marks.)1. The relationship among Database (DB), Database System (DBS) and DatabaseManagement System (DBMS) is ___A_____. A. “DBS includes DB and DBMS” B. “DBMS includes DB and DBS” C. “DB includes DBS and DBMS” D. “DB is DBS, also as DBMS”2. In an index, ___A_____ is the attribute to set of attributes used to look up records in afile.A. search keyB. structured keyC. sequence keyD. select key3. A _____D___ of an entity set is a set of one or more attributes whose values uniquelydetermine each entity. A. key B. primary key C. candidate key D. super key4. From the following physical storage media, ____D___ is VOLATILE .A. optical storageB. tape storageC. magnetic-diskD. main memory5. Choose the only one INCORRECT description from the followings: __D_____A. Neither tuples nor attributes have order.B. Attributes can appear in any order and the relation is still the same.C. Each value in the database must be a member of some domain.D. Duplicate tuples can exist in a relation.6. There is a relation R(A, B, C ) contains the following data. Which of the descriptionabout functional dependency is CORRECT? ___B_______ A. Functional dependence A → B holds on R. B. Functional dependence BC → A holds on R. C. Functional dependence B → A holds on R.D. Functional dependence A → BC holds on R.7. The right figure shows ___B_____ parallel databasearchitectures.A. ‘Shared memory’B. ‘Shared disk’C. ‘Shared nothing’D. ‘Hierarchical’8. Choose the proper choice to make the following SQL statement to realize query “Findthe names of all customers whose street end with the substring ‘%Dajie’”A B C 2 2 3 2 3 43 3 5 装订线班级:学号:姓名:A. LIKE ‘\%Dajie’SELECT customer_nameB. LIKE ‘\%Dajie%’FROM customerC. LIKE ‘%\%Dajie’WHERE customer_street ____C______D. LIKE ‘%\Dajie%’9.Suppose that there are two relations R(A, B) and S(B, C). Choose the equivalentrelational algebra expression for the following SELECT clause:_C__.A.∏A , B (σC≠‘C56’ (R S)) SELECT A, BB. ∏A , B (σC ≠ ‘C56’ (R S)) FROM RC. R- ∏A , B (σC = ‘C56’ (R S)) WHERE B NOT IN( SELECT BD. R- ∏A , B (σC ≠ ‘C56’ (R S)) FROM SWHERE C=’C56’)10.Choose the only one CORRECT expression about SQL from the followings:____C___.A. (≠ some) ≡ inB. (= all) ≡ not inC. EXISTS r ⇔r ≠ ØD. UNIQUE r ⇔r = ØII、Blank-filling questions.(Write your answers onto the answer sheet.) (There are7 questions and 10 blanks, totally 20 marks, each blank worth 2 marks.)1.To design a trigger mechanism, we must specify the ①under which thetrigger is to be executed; specify the ②to be taken when the trigger executes.①conditions , ②actions2.Given two original values A=300,B=150; compute both the values of Aand B after the transactions T1T2with the right side schedule.A= ;B= .A=225 ; B= 225 3.The basic query process has been list in the following figure, please fill the TWOblanks.1.①parser and translator , ②execution plan4.In physical level, the database is stored as a collection of files. Each file is a sequenceof records , each of which is a sequence of fields.5.Given 0.3ms as the time to transfer one block and 0.2ms as the time for one seek. Ifwe ignore CPU costs and the cost to writing output to disk, the cost is ___ 8 ______ ms for 20 block transfers and 10 seeks for simplicity.6.In database system, indexing mechanisms are used to speed up accessto desired data.7.In distributed database system, data is spread over multiple machines(also referred to as sites or nodes).III、B riefly description questions. (Write your answers onto the answer sheet.) (There are 4 questions, totally 16 marks, and each question worth 4 marks.)1.Please briefly list FOUR duties of a database administrator.2.Please give the definition and the ACID properties of transaction.3.Given the relation schema R = (A, B, C, G, H, I), and the functional dependency F = {A → B, A → C, CG → H, CG → I, B → H}. Explain whether AG → I and CG → HI are the members of F+? Why?AG →I is a member of F+.By augmenting A →C with G, to get AG →CG and then transitivity with CG →I, we can get AG →I.CG →HI is a member of F+.By augmenting CG →I to infer CG → CG I, and augmenting of CG →H to infer CGI →HI, and then transitivity, we can get CG →HI.4.Given the relation schema R = (A, B, C, G, H, I), and the functional dependency F = {A → B, A → C, CG → H, CG → I, B → H}. Compute (AG)+.The processes of computing result of (AG)+ have been shown below.① result = AG② result = ABCG (A →C and A → B)③ result = ABCGH (CG →H and CG ⊆AGBC)④ result = ABCGHI (CG →I and CG ⊆AGBCH)IV、Query questions. (Write your answers onto the answer sheet.) (There are 2 questions with 7 queries. There are totally 28 marks, each query worth 4 marks.)1.Consider the relational database of a banking enterprise with the following relation schemas, where the primary keys are underlined.branch (branch_name, branch_city, assets)customer (customer_name, customer_street, customer_city)loan (loan_number, branch_name, amount)borrower (customer_name, loan_number)account (account_number, branch_name, balance)depositor (customer_name, account_number)Give an expression in the relational algebra to express each of the following two queries:①Find the names of all customers who have a loan, an account, or both, from the bank.②Insert information in the database specifying that Smith has $4500 in account A-911 at the Perryridge branch.2.Consider the academic database contains three relations as the following 3 tables, andthen give an expression in SQL for each of the following queries.①Tip: Describe primary keys, foreign keys and check constrains if necessary. CREATE TABLE SC( Sno int,Cno int,Grade int,PRIMARY KEY (Sno, Cno),FOREIGN KEY (Sno) REFERENCES S,FOREIGN KEY (Cno) REFERENCES C,CHECK (Grade >= 0))②Find the student numbers and names of the male students, each of whom is older than 22-year-old.SELECT Sno, SNAMEFROM SWHERE AGE>22 AND SEX=‘M’;③Find the student numbers of the students, each of whom has at least chosen two courses.SELECT SnoFROM SC AS X, SC AS YWHERE X.Sno=Y.Sno AND o !=o④Find the names and ages of the male students, each of whom is older than all the female students.SELECT SNAME, AGEFROM SWHERE SEX=‘M’ AND AGE> ALL (SELECT AGEFROM SWHERE SEX=‘F’)⑤List the course name and average grade for all the courses which are taught by teacher LIU.SELECT CNAME, A VG(GRADE)FROM C, SCWHERE C.C#=SC.C# AND TEACHER=‘LIU’GROUP BY C.C#V、D esigning questions. (Write your answers onto the answer sheet.) (There are two questions, totally 16 marks. Question 1 worth 10 marks and question 2 worth 6 marks.)A university registrar’s office maintains data about the following entities:(a)students, including student-id, name, program;.(b)instructors, including id, name, department and title;(c)courses, including course number, title, credits, syllabus and prerequisites;(d)course offerings, including course number, year, semester, section number,instructor(s), timings, and classroom.Further, the enrollment of students in courses and grades awarded to students in each course they are enrolled for must be appropriately modeled.1.Construct an E-R diagram for the university registrar’s office. A class meets only at one particular place and time; y ou needn’t model a class meeting at different places at different times; also n eedn’t guarantee that the database does not have two classes meeting at the same place and time.2.Design a relational database, which is constructed by relation schemas, corresponding to the preceding E-R diagram with marked primary keys.。

《数据库原理(双语)》试卷

《数据库原理(双语)》试卷

D. specific19._________ takes a value of true if a subquery(子查询)returns an intermediateresults(中间结果) table which contains(包含)one or more rows.()A. InB. HavingC. ExistsD. Extents20。

A _________is a temporary table(临时表) used in the FROMclause(子句)of an SQL query.( )A. correlated subquery(相关子查询)B. derived table(导出表)C. view table(视图表)D. None of the above二、判断题(每题1分,共10分,正确的填T,错误的填F,将答案填在下表内)题号 1 2 3 4 5 6 7 8 9 10答案1。

We can define(定义)a relation schema(关系模式) R(A1, A2, A3)where A1 is the primary key(主键) and A3 is a foreign key(外键) that refers to(参考) R。

( )2.A constraint(约束) is a rule in a database system that can be violated(违反)by users.()3。

The E—R model is used to construct(构建) a conceptual model(概念模型)。

()4.The entity integrity rule(实体完整性规则)states that a primary key attribute can benull. ()5.The attribute value in a tuple(元组) that makes up(组成) a foreign key(外键)canbe null。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

关系数据库(高级)01一、填空题(每空2分,共20分)1. Once a user enters the data for his transaction, he can either commit the transaction to make the changes permanent or ______________________ the transaction to undo the changes.2. SQL consists of three components:Data Definition Language (DDL)Data Manipulation Language (DML)___________________________3. By use of the SQL statement ALTER, delete the column Item_Size from the table ITEMCOPY.__________________________________________________________________4. Using the SELECT option of the SQL statement CREATE TABLE, create a table named ITEMCOPY which is a copy of the table ITEM.__________________________________________________________________ 5. Create an index for the following column that allows duplicate data to be entered:Table: HOME Column: Home_Name__________________________________________________________________6. Create a view named ITEM_PRICELIST, on the table ITEM, which only includes the columns:Item_No, Item_Description, Item_Wholesale_Price, Item_Retail_Priceand sorts the result by the Item_Description.__________________________________________________________________ 7. Assign the appropriate privileges on the table ITEMCOPY to the last one of the users detailed below(HN92):__________________________________________________________________8. Create a synonym named ANOTHER_ITEM on the table ITEMCOPY.__________________________________________________________________ 9. Insert the following record into the Franchise table:Franchise No MF999Franchise Name Mature Fashions (Shetlands)Franchise Address 1, Lonely Spot, LerwickFranchise Postcode 2E1 1AAFranchise Tel 01595 1245Franchise Fax 01595 2356Franchise Start Date 22nd January 2002__________________________________________________________________ 10.Update the above record and change the address to 1, Main Street, Lerwick and the Start Date 15th February 2002.__________________________________________________________________二、判断以下的说法是否正确,如果正确,将在括号中,填入T(TRUE),否则,填入F(FALSE)。

(每小题1分,本大题共10分)1.SQL*Plus commands assist with querying data. ( )2. There are several different character datatypes in oracle: The CHAR datatype stores character values with a fixed length. The V ARCHAR2 datatype stores variable-length character strings. ( )3. The NULL value is one of the key features of the relational database. The NULL, in fact, doesn't represent any value at all—it represents the lack of a value.( ) 4. A view is an Oracle data structure constructed with a SQL statement. The SQL statement is stored in the database. Every view contains data. ( ) 5. An index is a data structure that speeds up access to particular rows in a database. An index is associated with a particular table and contains the data from one or more columns in the table. ( ) 6. The foreign key constraint is defined for a table (known as the child) that has arelationship with another table in the database (known as the parent). The valueentered in a foreign key must be present in a unique or primary key of another specific table. ( )7. The ANSI standard Structured Query Language (SQL) provides basic functions for data manipulation, transaction control, and record retrieval from the database,and most end users interact with Oracle through it. ( )8. The HA VING clause works in conjunction with the GROUP BY clause. That is, you cannot have a HA VING clause without a GROUP BY clause. ( )9. This SELECT statement will execute successfully .SELECT forename, surname, MIN(Salary) FROM employee; ( )10. This SELECT statement won’t execute successfully .SELECT date_of_birth, COUNT(*)FROM employeeGROUP BY date_of_birthHA VING COUNT(*) > 1; ( )三、简答题(每小题3分,共30分)Candidate InstructionsYou are required to answer each of the following 10 short response questions. The maximum marks for each question are shown in bracket.Read each question carefully, some ask you to qualify your answer with an example.1.In the following scenario identify the main entities. (3)The company ‘Hire a Wreck’ runs a car and van rental business at very competitive rates. Customers can hire vehicles on a daily or weekly period.A discount scheme is in operation whereby frequent customers are offered reducedhire rates. For legal reasons vehicles must be serviced on a regular basis.2. What is meant by the term entity occurrence? Illustrate your answer with an example. (3 )3. In a Relational Database System each entity must have a primary key defined. Give a definition of a primary key. Illustrate your answer withan example. (3 )4. A key may be defined as compound key. What is a compound key? Illustrate with an example. (3)5. From the following statements identify the degree of the relationships.The entities that are participating in the relationship are shown in quotes.a) A ‘customer’ may place one or more ‘orders’ each week.b) A ‘customer’ can order up to 5 different ‘products’ on an order. The same product can be ordered by different customers.c) A ‘salesman’ has a ‘company car’ that can onl y be driven by the salesman.d) Each ‘customer’ may have more than one ‘delivery address’.e) In a dental surgery a ‘dentist’ has many ‘patients’. At any one time a patient can only be registered with one dentist. However, over time a patient may register with different dentists.f) A ‘patient’ has many ‘appointments’.(3)6. An automated library system is to be implemented which will managethe loan of books to customers. Customers can take out up to 5 booksat a time. Each book has a defined loan period type (ie. P1=3 days,P2=7 days, P3=2 weeks, P4=1 month). Books are categorised into oneor more subject areas, eg geography, history, war, horror etc Thesystem will allow books to have joint authors. There is only one copy ofeach book in the library . (3)Using the scenario and entity relationship diagram above suggest suitable primary keys for:a) any two from Author, Book, Customer, Category and Loan Periodb) any two from Author/Book, Loan and Book/Category7. A relationship may be defined as being recursive. What is meant by theterm recursive relationship? Illustrate with an example. (3)8. An entity may have more than one choice for the primary key.What name is given to an alternative key? Illustrate your answer withan example. (3)9.Entities in a relational model are often inter-dependent upon one another.A special type of key implements these relationships. By what nameis that key known? Illustrate your answer with an example. (3)10. During entity modeling the degree of relationships (cardinality) are determined.There are three types of degrees of relationships, name them. (3)四、综合题(第1题共40分)1. You need to produce a report outlining the issues involved in the implementation of relational database systems.Candidate InstructionsThe object of this question is to allow you to become familiar with the main knowledge areas of RDBMSs to enable you to make informed and justifiable decisions on the implementation of relational database systems.You are required to produce a report on the topics detailed overleaf. The majority of issues should be illustrated using examples within the specific RDBMS chosen for delivery, ie. Oracle.The candidate will produce evidence in the form of a report outlining the issues involved in the implementation of relational database systems.The ReportThe report must include the following items:Data integrity measures: (200 to 300 words) (12)∙Transaction processing and the implications of rollback and commit∙Locking strategies covering read , write and shared locks∙Cascade events with reference to referential integrityThis section of the report is to be between 200 to 300 words in total.Definitions must be accurate and descriptions must be essentiallyaccurate but need not be comprehensive.Performance optimisation: (200 to 300 words) (12)Document the performance advantages and disadvantages of dataaccess for each of the following:∙Indexing versus full table scans∙Numeric versus non-numeric key values∙Maintaining versus calculating ‘calculated fields’This section of report may be tabular, graphical or textual and should be accompanied by brief descriptions and/or summaries between 200 to 300 words .2. You are required to design a relational database from a supplied case study. Candidate InstructionsData sources normalised to 3NF showing all intermediate stages(if preferred the normalisation from each data source may be submitted separately for marking before moving onto the next data source).Please show all the normalisation steps. each step (UNF, 1NF, 2NF, 3NF) and all keys (primary and foreign) must be clearly marked.Invoice ReportUNF1NF: (5)2NF: (5)3NF: (6)关系数据库(高级)01评分标准一、填空题(每空2分,共20分)1.rollback ;2. Data Control Language (DCL)3. ALTER TABLE itemcopy DROP COLUMN item_size;4. CREATE TABLE itemcopy AS SELECT * FROM item;5. CREATE INDEX home_name_index ON home (home_name);6. CREATE VIEW item_pricelist ASSELECT item_no, item_description, item_wholesale_price, item_retail_price FROM itemORDER BY item_description;7. GRANT select, insert, update, delete ON itemnosize TO HN92;8. CREATE SYNONYM another_item FOR itemcopy;9. INSERT INTO franchise VALUES( 'MF999', 'Mature Fashions (Shetlands)', '1, Lonely Spot, Lerwick', '2E1 1AA', '01595 1245', '01595 2356', '22/Jan/2002', 'MF000');10. UPDATE franchiseSET franchise_address = '1, Main Street, Lerwick', franchise_startdate = '15/Feb/2002'WHERE franchise_no = 'MF999';二、判断以下的说法是否正确,如果正确,将在括号中,填入T(TRUE),否则,填入F(FALSE)。

相关文档
最新文档