# Department of Computer Science 2015/16

Size: px
Start display at page:

## Transcription

1 LUND INSTITUTE OF TECHNOLOGY Database Technology Department of Computer Science 205/6 Exercises, Database Technology These are self-study exercises with solutions. Exercise E/R modeling Objective: to practice E/R modeling.. A calendar program that allows users to browse each other s calendars and to book common appointments shall be developed. The program has a database which keeps track of the users and their calendars. You use the calendar to store data concerning appointments. An appointment starts and ends at a given time on a given day and is described by a text. You may specify that you wish to be reminded of an appointment. Reminders are of different kinds: a signal in the computer s loudspeaker, a pop-up window with the description of the meeting, or an containing the description. You may, for each reminder, specify how long before the appointment that you wish to be reminded. Develop an E/R model of the database. 2. A TV company wishes to develop a database to store data about the TV series that the company produces. The data includes information about actors who play in the series, and directors who direct the episodes of the series. Actors and directors are employed by the company. A TV series are divided into episodes. Each episode may be transmitted at several occasions. An actor is hired to participate in a series, but may participate in many series. Each episode of a series is directed by one of the directors, but different episodes may be directed by different directors. Examples of database queries: Which actors play in the series Big Sister? In which series does the actor Bertil Bom participate? Which actors participate in more than one series? How many times has the first episode of the series Wild Lies been transmitted? At what times? How many directors are employed by the company? Which director has directed the greatest number of episodes? Develop an E/R model of this system. Find attributes of the entity sets. Determine which of the attributes that can be used as primary keys. 3. Develop an E/R model of a database that is to be used in the following system: A homeowners association (that is, an association of people who own apartments) owns a parking lot. The parking lot has a number of parking spaces. The owners and their guests may freely use all the parking spaces, except some spaces that have electric sockets for engine heaters. Such a parking space is rented by one of the apartment owners, who has exclusive use of the space. The rent for the space is added to the apartment rent.

2 2 Exercise E/R modeling The spaces with electric outlets are popular, and there is a queue of apartments that wish to rent such a space. Each apartment may have at most one place in the queue. When a space becomes available, the apartment with the longest queue time may rent it. One of the apartment owners must sign the contract (an apartment may have more than one owner, and an owner may own more than one apartment). The association sometimes has problems with scrap cars that are deposited in the parking lot. It is often a difficult procedure to get rid of these cars. Discovery of a scrap car must be registered in the database, as well as each thing that happens with the car (Parking space 43: Discovered suspect car, license number XYZ789, Called the police about the car, and so on). 4. A municipality needs a database containing information concerning the inhabitants of the municipality. The database will be used for the planning of schools, health care and child care. From the database, you should be able to receive answers to queries of the following types: How many boys and girls will start school during year x? How many people will become old-age pensioners during year x? How many households have more than x people? How many people are single parents? In how many households is at least one member unemployed? How many households have a total income that is less than the norm for receiving social benefits? Develop an E/R model of the database, including attributes and primary keys. Carefully consider the representation of household and parent.

4 4 Exercise 2 from E/R to relations, SQL The database also contains data about diseases. Each disease is characterized by different symptoms: a patient with a cold should have fever and a cough, a malaria patient should have fever and fits of shivering, etc. a) Describe this system in an E/R model. b) Translate the E/R model into a relational model. c) Write SQL statements that answer the following questions (you may define and use views, if you wish). Find the s of all patients that: don t have any symptom of high severity, have at least two different symptoms, have at least one of the symptoms of malaria, have all the symptoms of malaria. 4. Shops sell items at varying prices. Customers buy items from shops. This is described by the following relations: Shops(shopId,, address) Items(itemId,, description) Sells(shopId, itemid, price) Customers(customerId,, address) Sales(saleId, customerid, itemid, shopid, date) Draw a diagram in question??, write SQL statements in questions???? (you may create and use views). a) Draw an E/R diagram that describes the database. b) Create the table Sells. Invent suitable types for the attributes (itemid shall have the type char(0)) and indicate reasonable integrity constraints. c) Print the and address of all customers who haven t bought any item. d) Print the number of shops that sell items with id s starting with EF. e) Print the and address of the shop(s) that sell the item with id = EF23-A at the lowest price. f) For all customers that have bought at least one item: print the customer id and the total sum of all purchases.

5 Exercise 3 FD s and normalization 5 Exercise 3 FD s and normalization Objective: to practice finding functional dependencies, finding keys and normalizing relations.. The relation R(A, B, C, D, E) has the following functional dependencies: FD. FD2. FD3. FD4. FD5. A C B D AC D CD E E A Determine all the keys of the relation. 2. The relation R(A, B, C, D) has the following functional dependencies: FD. FD2. FD3. D AC A B B C a) What are the keys of the relation? b) Show that the relation is not in BCNF and not in 3NF. c) Decompose the relation into smaller relations that are in BCNF. 3. A company has several employees, all with different s, who perform interviews with job applicants (one applicant is interviewed by one employee). The job applicants also have different s. The interviewer makes appointments for interviews with the applicants. Each applicant may be interviewed at several occasions, possibly by different interviewers, but in that case the interviews take place during different days. The company has special interview rooms. Each interviewer uses the same room for all interviews during a day. A room may, however, be used by different interviewers during a day, as long as the interviews don t collide in time. The reservation of interview appointments is to be computerized. The database developer has decided to use a single relation for all data, with the following schema: Interviews(interviewer, applicant, day, time, room) a) From the text, find functional dependencies in the relation. b) Find the keys of the relation. c) Show that the relation is in 3NF but not in BCNF. d) Decompose the relation in relations that are in BCNF. e) Extra assignment: draw an E/R diagram that describes the system. Try to incorporate all dependencies from the text in the diagram (not easy). 4. We wish to develop a database to keep track of persons, their children and their cars. For this purpose, we will use the following relation: PersonData(pNbr, pname, paddress, cnbr, cname, caddress, alic, amake) pnbr, pname, paddress is the person number, and address of a person. cnbr, cname, caddress is the corresponding information for a child. Each person has exactly one address. alic, amake is the license number and make of a car. A car may be owned by more than one person. a) What are the functional dependencies in this relation?

6 6 Exercise 3 FD s and normalization b) Find the keys of the relation and show that the relation is not in BCNF. c) Decompose the relation into relations that are in BCNF. d) Show that one of the resulting relations violates the 4NF condition. e) Decompose this relation into relations that are in 4NF. f) Draw an E/R diagram that describes the problem and use this diagram to create relations. Persons and children are considered to be different entity sets. Are the resulting relations the same as the ones that you created in questions?? and???

7 Exercise 4 database design 7 Exercise 4 database design Objective: to practice formulating simple queries in relational algebra. Then, you will summarize your database knowledge by designing two databases.. A company organizes its activities in projects. Products that are used in the projects are bought from suppliers. This is described in a database with the following schema: Projects(projNbr,, city) Products(prodNbr,, color) Suppliers(supplNbr,, city) Deliveries(supplNbr, prodnbr, projnbr, number) Write relational algebra expressions that give the following information: a) All information about all projects. b) All information about all projects in London. c) The supplier numbers of the suppliers that deliver to project number 23. d) The product numbers of products that are delivered by suppliers in London. e) All pairs of product numbers such that at least one supplier delivers both products. 2. Another company also organizes its activities in projects. Each project has a and is run at a specific location. Unfortunately, there are several projects with the same it may even be the case that two projects with the same are run at the same location. Each project has a telephone, which is shared if there is more than one project at the same location. Each project has a boss, who is one of the employees of the company. Each company employee has a person number, address and telephone number. Many of the employees have several telephone numbers (office telephone, cellular, cellular 2,... ). The employees work in the projects, most of them in more than one project. Each such project employment starts at a specific date and ends at another date (the end date of current project employments is unknown). a) Describe the structure of the company in an E/R model. b) Convert the E/R model to a relational model. Indicate attributes that are primary keys and foreign keys. c) Prove that the relations are in BCNF. 3. In a botanical survey, an inventory is made of the Swedish flora, i.e., it is investigated where different plants grow. Plants are identified by their Latin s: Anemone nemorosa, Ranunculus ficaria, etc. The survey is made at different sites. A site is described by its ( The Midsummer Meadow in Stolphult ), its type ( meadow ), and its coordinates in the coordinate system Swedish Grid ( 5300E, N ). At a site, investigations are performed in m squares. Each square also has coordinates, which are measured relative to the site coordinates. For each plant that occurs in a square, the degree of coverage (in percent) is recorded. Chemical analyses of different chemical properties are performed in some of the squares. Which analyses that are performed may vary, but common measurements are ph and the content of different heavy metals. The results of the measurements are given in different units: no unit, ppm, etc. However, there are employees who have worked in the same project during all their time in the company. Furthermore, there are employees who do not participate in a project, e.g., new employees.

8 8 Exercise 4 database design The survey involves a lot of people. Each person has a person number,, and address. Each square is investigated by one person. a) Develop an E/R model that describes the survey. b) Translate the E/R model into a relational model. All relations must be in BCNF (prove, or at least motivate carefully, that this is the case). Indicate primary keys and foreign keys in all relations. c) Using your relations in question??, write an SQL statement that gives the s of all plants that occur in squares that have a ph value less than 4.

9 Exercise Solutions 9 Exercise Solutions. We start by identifying candidates for entity sets, for example by writing down the nouns and noun phrases in the requirements specification. We obtain the following list: Calendar program, user, calendar, appointment, program, database, track, data, time, day, text, reminder, kind, signal, computer, loudspeaker, pop-up window, description, meeting, . Not all of these candidate are suitable entity sets. We discard most of the candidates, for the following reasons: Irrelevant Calendar program, program, database, track, kind, computer, loudspeaker Attributes time, day, text (of appointment), time (of reminder) Operations Redundant data (same as attributes of appointment), description (of appointment, same as text), meeting (same as appointment) Misleading s Remaining candidates: user, calendar, appointment, reminder, signal/pop-up window/ . Relationships from the requirements specification: users browse each other s calendars users have calendars calendars store appointments appointments may be in several calendars appointments may have reminders An obvious generalization is that there are three kinds of reminders: signal, pop-up window, . This results in the following E/R diagram: User..* Calendar owns stores looks-at Appointment date starttime endtime text has 0.. Reminder timebefore Beep Popup The relationship has between Appointment and Reminder seems to express what we wish, but note that it says that an appointment has the same reminder in all calendars. If an appointment could have different reminders in different calendars, we can make Reminder an association class on the relationship stores between Calendar and Appointment. Note that this is a conceptual E/R model, not a database model. Before we can transform the E/R model into a relational model we must study it closer and modify it quite a lot. For instance, the relationship looks-at will only be necessary if it has

10 0 Exercise Solutions attributes, e.g., if users only have access to certain other calendars. The entity sets User and Calendar are not complete they don t have any attributes, and we cannot form a key for the entity sets. Probably, this doesn t mean that the entity sets are unnecessary, but rather that we haven t yet found any suitable attributes. Appointment also needs an attribute that can be used as a key. Finally, we can note that Reminder, at least in its present form, is a weak entity set. 2. We use the same procedure as in question??. First, candidates for entity sets: TV company, database, data, TV series, company, information, actor, series, director, episode, occasion. Discarded candidates: Irrelevant database, data, information Attributes occasion (the time when an episode is shown) Operations Redundant company (same as TV company, series (same as TV series) Misleading s Since each episode may be transmitted at several occasions we need an entity set to hold the transmission time. This entity set we call Transmission. We also need an entity set that describes the common features of actors and directors, ly that they are employed by a TV company. We call this entity set Employee. Entity sets Actor and Director will be subentities to Employee. E/R diagram: TV company TV series <<weak>> Episode number Employee address salary <<weak>> Transmission time Director Actor From the requirements specification we only obtain the attribute time in Transmission. Other attributes have been invented. Entity sets Episode and Transmission are weak. To form the key for Episode, number alone does not suffice: you need to know the of the TV series as well. Similarly for Transmission: the time, episode number, and TV series together form the key. We can check that it is possible to answer the database queries using only the E/R diagram. To check that we can answer the query Which actors play in the series Big Sister? we check that there is a relationship between the involved entity sets, here Actor and TV series. We can also check more complex queries, for instance At what times can we see the actor Bertil Bom?. By starting in Actor and following relationships we first reach the TV series in which Bertil Bom participate, then the episodes of this series, then the transmissions of the episodes, and there we find the times. (In the database this will correspond to select statements with several relations, joins.)

11 Exercise Solutions 3. E/R diagram: <<weak>> QueuePlace entrydate 0.. Parkingspace nbr haselectricity monthlyrate 0.. <<weak>> Contract date Apartment nbr 0.. ProblemCar licnbr <<weak>> ProblemNote date info Owner pnbr address 4. Suggested entity sets: person, household. Reasons for this choice: Inhabitant means the same as Person, which is a better. Boy and girl are not entity sets the gender of a person is coded into the person number, which is an attribute. Pensioner is not an entity set the year of birth of a person is coded into the person number. Parent is not an entity set the parenthood is introduced when a person has children, and this will be described by a relationship. Attributes of the entity set Person (minimal set): person number (containing year of birth and gender), employed/unemployed, income. Household attributes: household number (or something else that uniquely identifies a household). E/R diagram: Household nbr 0.. belongs-to parent-in 0..2 Person personnbr employment income Note especially the relationship parent-in. This relationship does not describe a biological parenthood, only that the person is considered to be a parent in a household. This will make it easy to handle people that are divorced and later form a new household with a new set of children.

12 2 Exercise 2 Solutions Exercise 2 Solutions. We start with the entity sets. There are two entity sets that must be converted into relations, and where we don t have any alternatives for the implementation (primary keys are underlined): Products(productId, ) Suppliers(supplierId,, address) The many-many relationships must also be converted into relations (foreign keys are in italics): ProductParts(productId, partid) PartSuppliers(partId, supplierid, unitprice) When we are to translate the hierarchical structure, we have three alternatives: E/R, OO and NULLS (see the course book). We get the following relations for the three alternatives: E/R: OO: NULLS: Parts(partId,, qtyinstock) ManufacturedParts(partId, manfcost) PurchasedParts(partId) Parts(partId) ManufacturedParts(partId,, qtyinstock, manfcost) PurchasedParts(partId,, qtyinstock) (The relation Parts is necessary because the foreign key partid in the relation ProductParts must lead to one relation.) Parts(partId, typecode,, qtyinstock, manfcost) (The type code specifies whether the part is manufactured or purchased. If there had been any attributes in PurchasedParts, all of them would have become part of the relation.) Typical tasks that have to be solved: Change a product so it contains a new manufactured part: E/R: OO: NULLS: Insert a new tuple in Parts and one in ManufacturedParts. Insert a new tuple in Parts and one in ManufacturedParts. Insert a new tuple with the corresponding type code in Parts. Regardless of which alternative we use, we also must insert a new tuple in Product- Parts. Update the stock (qtyinstock) when a purchased part is delivered: E/R: OO: NULLS: Change a tuple in Parts. Change a tuple in PurchasedParts. Change a tuple in Parts.

13 Exercise 2 Solutions 3 Find the total cost to produce a product: E/R: OO: NULLS: Find all parts from ManufacturedParts that are part of the product, sum all manfcosts. Do the same for PurchasedParts, but sum all the corresponding unitprices from PartSuppliers. Same as E/R. Find all parts from Parts with typecode manufactured, sum the manf- Costs. Then sum the unitprices for the parts with type code purchased. In this model, it is difficult to find types of questions that demand that you, starting from a subclass, need to find the superclass to get information or vice versa. In such questions, the E/R variant requires that you make a join on the subclass table and the superclass table. (An invented example of such a question: Given the of a manufactured part, find the price of that part.) An advantage of hierarchical modeling should be that it is easy to introduce new subclasses. In this case it will probably not be relevant it is hard to imagine a third category of parts that you do not either manufacture or purchase. If you do introduce a third category, it will lead to substantial changes in the database schema or in the SQL questions, regardless of which variant of translation you have used. 2. We choose to implement the many-one relationships by inserting the key from the one side into the relation created from the entity set on the many side. Review is weak, but the key {customernbr, itemid, date} is too long, so we add a key reviewid. Relations: Customers(customerNbr,, address, creditcardnbr, , newsletter) Items(itemId, itemtype, title, price, date, nbrinstock, avggrade, nbrvotes) ShoppingCarts(cartId, complete, customernbr) Types(type) Categories(category) Reviews(reviewId, date, text, customernbr, itemid) ItemsInShoppingCart(itemId, cartid, isdelivered, deliverydate) ItemsInCategories(itemId, category)

14 4 Exercise 2 Solutions 3. E/R diagram: severity Patient pnbr address shows Symptom description..* appears-in Disease description We have two many-many relationships, so if we merge all entity sets into one relation the resulting relation will not be in 4NF. But we, of course, use the ordinary method to convert the E/R diagram into relations, and we get the following relations: Patients(pNbr,, address) Symptoms(, description) Diseases(, description) PatientSymptoms(patientNbr, symptomname, severity) DiseaseSymptoms(diseaseName, symptomname) All these relations are in 4NF the only functional dependencies are the key dependencies and there are no multivalued dependencies. Patients that have no symptoms with high severity: select from Patients where pnbr not in (select patientnbr from PatientSymptoms where severity = high ); Patients that have at least two different symptoms: create view SymptomCount as select patientnbr, count(*) nbrsymptoms from PatientSymptoms group by patientnbr; select from Patients, SymptomCount where pnbr = patientnbr and nbrsymptoms >= 2; Patients that have at least one of the symptoms of malaria: create view MalariaSymptoms as select symptomname from DiseaseSymptoms where diseasename = Malaria ; select patientnbr from PatientSymptoms, MalariaSymptoms where PatientSymptoms.symptomName = MalariaSymptoms.symptomName group by patientnbr having count(*) >= ; Patients that have all symptoms of malaria (the view MalariaSymptoms is used here, too):

15 Exercise 2 Solutions 5 select patientnbr from PatientSymptoms, MalariaSymptoms where PatientSymptoms.symptomName = MalariaSymptoms.symptomName group by patientnbr having count(*) = (select count(*) from MalariaSymptoms); The last two queries give us person numbers instead of s. To find the s, you can use the query as a subquery, e.g., like this: select from Patients where pnbr in (select patientnbr from PatientSymptoms, MalariaSymptoms where PatientSymptoms.symptomName = MalariaSymptoms.symptomName group by patientnbr having count(*) = (select count(*) from MalariaSymptoms)); 4. E/R diagram: Customer customerid address Sale saleid date Shop shopid address Item itemid description price create table Sells ( shopid char(0), itemid char(0), price double not null, primary key (shopid, itemid), foreign key (shopid) references Shops(shopId), foreign key (itemid) references Items(itemId) ); select, address from Customers where customerid not in (select customerid from Sales); select count(distinct shopid) from Sells where itemid like EF% ; select, address from Shops natural join Sells where itemid = EF23-A and price = (select min(price) from Sells where itemid = EF23-A ); select customerid, sum(price) from Sales natural join Sells group by customerid;

16 6 Exercise 3 Solutions Exercise 3 Solutions. To find the keys we must calculate the closures of all subsets of all combinations of attributes, i.e., {A} +, {B} +,..., {AB} +, {AC} +,... If the closure of a subset contains all attributes of the relation, the subset is a key. Observation that makes things easier in the future: since B does not appear on the right-hand side of any of the functional dependencies, all keys must contain B. Thus, we only need to consider subsets that contain B. The functional dependencies were: FD. FD2. FD3. FD4. FD5. A C B D AC D CD E E A Calculation of closures, subsets with one attribute that contain B: {B} + {B} FD2 {BD} Subsets with two attributes, containing B: {AB} + {AB} FD {ABC} FD2 {ABCD} FD4 {ABCDE} {BC} + {BC} FD2 {BCD} FD4 {BCDE} FD5 {ABCDE} {BD} + {BD} {BE} + {BE} FD2 {BDE} FD5 {ABDE} FD {ABCDE} {AB}, {BC} and {BE} are keys. Subsets with three attributes that contain B: {ABC}, {ABD}, {ABE} all of these contain {AB}, so they do not need to be studied (they are superkeys). {BCD}, {BCE} contain {BC}. {BDE} contains {BE}. Similar reasoning shows that we don t need to study larger subsets. 2. To find the keys we do as in the previous assignment, i.e., calculate the closures of all subsets of the set of attributes. But the attribute D doesn t appear on the right-hand side of any of the dependencies, so it must be included in the key. FD. FD2. FD3. D AC A B B C Closure of the subset {D}: {D} + FD {DAC} FD2 {DACB} The closure contains all attributes so {D} is a key. It is the also the only key: all sets of two or more attributes that contain D are superkeys. FD2 and FD3 violate the BCNF condition, since the left-hand sides (A, B) aren t superkeys. The relation isn t in 3NF, since the right-hand sides of FD2 and FD3 (B, C) aren t part of the key.

17 Exercise 3 Solutions 7 We decompose starting from FD2 and get: R(A, B) R2(A, C, D) R is in BCNF, since it has two attributes. R2 isn t in BCNF, since it has the same key as R and the dependency A C (obtained from FD2 and FD3 and the transitive rule). We split R2 using A C: R2a(A, C) R2b(A, D) Both these relations have only two attributes and are in BCNF. 3. Functional dependencies: FD. FD2. FD3. applicant day interviewer time room (Each day an applicant is interviewed, the interview is performed by a certain interviewer at a certain time in a certain room.) day time room interviewer applicant (An interview room is booked for a certain time by an interviewer, for an interview with a certain applicant.) interviewer day room (An interviewer uses the same room for all interviews during one day.) FD and FD2 contain all attributes so {applicant, day} and {day, time, room} are keys. (You must also check that no subsets of these sets are keys. This is easy to do.) There is one more key by computing closures you obtain: FD4. interviewer day time applicant room (At any time, an interviewer only interviews one applicant.) The relation is not in BCNF because of FD3: {interviewer, day} is not a superkey. But the relation is in 3NF, since the right-hand side of FD3, room, is part of a key. Conversion to BCNF: take one of the functional dependencies that violate the BCNF conditions. Here we have only one such dependency, FD3. Create a new relation with the attributes that appear in FD3, and another relation with all attributes except those on the right-hand side of FD3: R(interviewer, day, room) R2(interviewer, day, time, applicant) R states that an interviewer books one room for all interviews during one day and should be called RoomBookings, for example. R2 states that an interviewer books times for interviews with the applicants and should be called Interviews, for example. RoomBookings has the key {interviewer, day} (from FD3). Interviews has the keys {interviewer, day, time} (from FD4) and {applicant, day} (from FD). Both relations are in BCNF. First draft of an E/R diagram:

18 8 Exercise 3 Solutions Interviewer Interview day time room Applicant Note that the only FD that is visible in the diagram is FD2, day time room interviewer applicant. If you, according to the rules, transform the E/R diagram into relations, you obtain the following relations: Interviewer() Applicant() Interviews(interviewerName, applicantname, day, time, room) That is, the same unnormalized relation Interviews as you started with! This shows that even a good E/R model can result in unnormalized relations, if there are conditions (in this case the functional dependencies) that are difficult to express in the E/R model. You can, after a lot of thought, develop an E/R model where most of the functional dependencies are expressed. Days and rooms must be entity sets, and it may look like this: Interviewer interview Applicant RoomBooking room time Day day From this model you get the normalized relations: RoomBookings(interviewerName, day, room) Interviews(interviewerName, day, time, applicantname) The question is if it was worth the trouble. I don t think so: the first E/R diagram is easy to understand, the second is very detailed and hard to understand. It is better that the E/R model is easy to understand than that it is complete, especially since it is easy to normalize relations afterwards. 4. We start with an example that shows that the relation contains redundant information: Nils (person number ) and Anna (person number 222) live in Lund and have a daughter, Eva, and a car, ABC23: pnbr pname paddress cnbr cname caddress alic amake Nils Lund 333 Eva Lund ABC23 Toyota 222 Anna Lund 333 Eva Lund ABC23 Toyota If Nils and Anna get a son, Johan, and also buy a new car, DEF456, the relation will look like this:

19 Exercise 3 Solutions 9 pnbr pname paddress cnbr cname caddress alic amake Nils Lund 333 Eva Lund ABC23 Toyota 222 Anna Lund 333 Eva Lund ABC23 Toyota Nils Lund 444 Johan Lund ABC23 Toyota 222 Anna Lund 444 Johan Lund ABC23 Toyota Nils Lund 333 Eva Lund DEF456 Ford 222 Anna Lund 333 Eva Lund DEF456 Ford Nils Lund 444 Johan Lund DEF456 Ford 222 Anna Lund 444 Johan Lund DEF456 Ford Here the same information is repeated several times, so the relation obviously isn t normalized. It remains to prove this. We start by looking at functional dependencies. The person number is used to identify persons, and the license number is used to identify cars, so the following functional dependencies hold: FD. FD2. FD3. pnbr pname paddress cnbr cname caddress alic amake The relation has the key {pnbr, cnbr, alic}, so all functional dependencies violate the BCNF rules. If we decompose the relation to get BCNF relations we obtain, after several steps: Persons(pNbr, pname, paddress) Children(cNbr, cname, caddress) Automobiles(aLic, amake) PersChildAuto(pNbr, cnbr, alic) The first three relations contain no redundant information, but the relation PersChildAuto does. With the same data as in the example above, the relation instance looks like this: pnbr cnbr alic 333 ABC ABC ABC ABC DEF DEF DEF DEF456 As an example of redundancy, it is stated twice that person has a child 333. This must be so, since owns two cars. The relation PersChildAuto has no functional dependencies at all, so it is in BCNF. But each person has a well-defined set of children and a well-defined set of cars, and these sets are independent of each other. This is called a multivalued dependency. The following multivalued dependencies hold (multivalued dependencies always occur in pairs):

20 20 Exercise 3 Solutions MVD. MVD2. pnbr cnbr pnbr alic PersChildAuto is not in 4NF, since pnbr is not a superkey. We can decompose the relation using one of the multivalued dependencies, in the same way as when we decompose relations into BCNF. We get: HasChildren(pNbr, cnbr) OwnsAutos(pNbr, alic) If we develop an E/R model starting from the original formulation of the problem we get, without much trouble, the following diagram: Automobile alic amake Person Child pnbr pname paddress cnbr cname caddress From this, we get the same normalized relations as above.

21 Exercise 4 Solutions 2 Exercise 4 Solutions. Expressions in relational algebra: a) Projects b) σ city= London (Projects) c) π supplnbr (σ projnbr=23 (Deliveries)) d) π prodnbr (σ city= London (Deliveries Suppliers)) e) π L.prodNbr,L2.prodNbr (σ L.prodNbr<L2.prodNbr (ρ L (Deliveries) L.supplNbr=L2.supplNbr ρ L2(Deliveries)) ρ is the renaming operator: ρ L (Deliveries) res Deliveries to L. 2. We develop this solution in several steps. We start by describing that there are employees and projects, and that employees work in projects. Employments have start and end dates. We have tried to include most of the attributes: Employee persnbr address telephonenbr works-for Employment startdate enddate Project location telephonenbr We haven t expressed that each project has a boss. This is best expressed by a relationship between Project and Employee. We don t need an entity set for the bosses according to the text, they don t have additional properties compared to other employees. With this relationship, the diagram looks like this: boss-of 0.. Employee persnbr address telephonenbr works-for Employment startdate enddate Project location telephonenbr We allow a boss to manage more than one project, and we also allow projects without a boss. The text says that each project should have a boss, but it seems reasonable that a project, at least temporarily, stands without a boss. The entity set Employee has telephonenbr as an attribute. All attributes must be simple, i.e., this model specifies that an employee has one telephone number. This wasn t the case, according to the specification, and we must be able to describe that an employee has many telephone numbers. The only way to achieve this is to introduce a new entity set and a relationship with multiplicity many. We have done this in the following diagram (since we now have an entity set describing telephones we also have removed the telephone number from the project it is better to describe a thing in only one place):

22 22 Exercise 4 Solutions boss-of 0.. Employee persnbr address 0.. works-for Employment startdate enddate Project location has-phone Telephone telephonenbr has-phone By using 0.. and as multiplicities on the relationships from Telephone we have tried to express that a telephone is owned by an employee or a project (or several projects). It mustn t happen that the multiplicity is non-zero for both relationships at the same time. (UML has notation to express such restrictions, but we haven t learned this.) Before translating the E/R model into relations we study the keys of the entity sets. Employee has the key persnbr and Telephone has the key telephonenbr. We cannot form a key for Project, since several projects may have the same. This could indicate that Project is a weak entity set and that we should fetch the key from another entity set, but that doesn t seem to be the case here we cannot reasonably use a person number or a telephone number to identify a project. The only way out is to invent a key for projects. We call the key projnbr, but we don t show the E/R diagram again. The entity sets are translated into the following relations: Employees(persNbr,, address) Projects(projNbr,, location) Telephones(telephoneNbr) The relationship works-for has multiplicity many-many, so this must become a relation: Employments(projNbr, persnbr, startdate, enddate) For the remaining relationships, with multiplicity or 0.., we have several options. We start by looking at boss-of. One option is to create a relation for this relationship: BossOf(projNbr, persnbr) But since each project has exactly one boss, or maybe no boss, we can instead insert the corresponding key into the relation on the many side, i.e., in Projects: Projects(projNbr,, location, bosspersnbr) In a project without a boss, bosspersnbr is null. The employee telephones can be treated in the same fashion. Telephones will look like this: Then, the relation Telephones(persNbr, telephonenbr) We cannot put the project telephones in this relation, and it seems unnecessary to create a separate relation for the relationship between project and telephone. Since each project only has one telephone we can insert the telephone number in the project relation:

23 Exercise 4 Solutions 23 Projects(projNbr,, location, bosspersnbr, telephonenbr) To summarize, we have created the following relations: Employees(persNbr,, address) Telephones(persNbr, telephonenbr) Projects(projNbr,, location, bosspersnbr, telephonenbr) Employments(projNbr, persnbr, startdate, enddate) The relation Telephones now only contains data concerning employee telephones, and we should change the of the relation to, for example, EmployeeTelephones. Are these relations normalized? Yes, the relations that only have key dependencies are, but this is not the case for all of the relations. The relation: Projects(projNbr,, location, bosspersnbr, telephonenbr) has a functional dependency in addition to the key dependency. The text says that... has a telephone, which is shared if there is more than one project at the same location. This means that the location owns the telephone, not the project. In other words, we have the functional dependency location telephonenbr. Location is not a superkey, and the relation isn t in BCNF. We normalize the relation by splitting it in two: LocationTelephones(location, telephonenbr) Projects(projNbr,, location, bosspersnbr) Resulting relations: 3. E/R diagram: Employees(persNbr,, address) EmployeeTelephones(persNbr, telephonenbr) Projects(projNbr,, location, bosspersnbr) LocationTelephones(location, telephonenbr) Employments(projNbr, persnbr, startdate, enddate) Person pnbr address Site type xcoord ycoord <<weak>> Square dx dy Meaurement value MeasuredQuantity unit Observation coverage Plant

24 24 Exercise 4 Solutions Square is a weak entity set, since the coordinates are relative to the coordinates of the site. Relations from the entity sets (will be modified later): Sites(, type, xcoord, ycoord) Squares(siteName, dx, dy) Plants() MeasuredQuantities(, unit) Persons(pNbr,, address) Relations from the relationships: Observations(plantName, sitename, dx, dy, coverage) Measurements(measuredName, sitename, dx, dy, value) InventoryResponsible(siteName, dx, dy, pnbr) The key in Squares is too complex it is difficult to handle when it is to be used as a foreign key in other relations. Therefore, we choose to identify a square by a unique number, squareid. We also delete the relation InventoryResponsible, and instead introduce the person number of the responsible person as a foreign key in Square. Resulting relations: Sites(, type, xcoord, ycoord) Squares(squareId, sitename, dx, dy, responsiblepnbr) Plants() MeasuredQuantities(, unit) Persons(pNbr,, address) Observations(plantName, squareid, coverage) Measurements(measuredName, squareid, value) In addition to the indicated primary keys, {xcoord, ycoord} is a key in Sites, as is {sitename, dx, dy} in Squares. There are no functional dependencies beside the key dependencies, so the relations are in BCNF. All plants that occur in squares that have a ph value less than 4: select distinct plantname from Measurements, Observations where measuredname = ph and value < 4 and Measurements.squareId = Observations.squareId;

### Lecture Notes on Database Normalization

Lecture Notes on Database Normalization Chengkai Li Department of Computer Science and Engineering The University of Texas at Arlington April 15, 2012 I decided to write this document, because many students

### LiTH, Tekniska högskolan vid Linköpings universitet 1(7) IDA, Institutionen för datavetenskap Juha Takkinen 2007-05-24

LiTH, Tekniska högskolan vid Linköpings universitet 1(7) IDA, Institutionen för datavetenskap Juha Takkinen 2007-05-24 1. A database schema is a. the state of the db b. a description of the db using a

### Graham Kemp (telephone 772 54 11, room 6475 EDIT) The examiner will visit the exam room at 15:00 and 17:00.

CHALMERS UNIVERSITY OF TECHNOLOGY Department of Computer Science and Engineering Examination in Databases, TDA357/DIT620 Tuesday 17 December 2013, 14:00-18:00 Examiner: Results: Exam review: Grades: Graham

### Databases -Normalization III. (N Spadaccini 2010 and W Liu 2012) Databases - Normalization III 1 / 31

Databases -Normalization III (N Spadaccini 2010 and W Liu 2012) Databases - Normalization III 1 / 31 This lecture This lecture describes 3rd normal form. (N Spadaccini 2010 and W Liu 2012) Databases -

### Functional Dependencies and Normalization

Functional Dependencies and Normalization 5DV119 Introduction to Database Management Umeå University Department of Computing Science Stephen J. Hegner hegner@cs.umu.se http://www.cs.umu.se/~hegner Functional

### Design of Relational Database Schemas

Design of Relational Database Schemas T. M. Murali October 27, November 1, 2010 Plan Till Thanksgiving What are the typical problems or anomalies in relational designs? Introduce the idea of decomposing

### Relational Normalization Theory (supplemental material)

Relational Normalization Theory (supplemental material) CSE 532, Theory of Database Systems Stony Brook University http://www.cs.stonybrook.edu/~cse532 2 Quiz 8 Consider a schema S with functional dependencies:

### Database Design and Normalization

Database Design and Normalization Chapter 10 (Week 11) EE562 Slides and Modified Slides from Database Management Systems, R. Ramakrishnan 1 Computing Closure F + Example: List all FDs with: - a single

### Database Design and Normalization

Database Design and Normalization CPS352: Database Systems Simon Miner Gordon College Last Revised: 9/27/12 Agenda Check-in Functional Dependencies (continued) Design Project E-R Diagram Presentations

### Introduction to Databases, Fall 2005 IT University of Copenhagen. Lecture 5: Normalization II; Database design case studies. September 26, 2005

Introduction to Databases, Fall 2005 IT University of Copenhagen Lecture 5: Normalization II; Database design case studies September 26, 2005 Lecturer: Rasmus Pagh Today s lecture Normalization II: 3rd

### SQL DDL. DBS Database Systems Designing Relational Databases. Inclusion Constraints. Key Constraints

DBS Database Systems Designing Relational Databases Peter Buneman 12 October 2010 SQL DDL In its simplest use, SQL s Data Definition Language (DDL) provides a name and a type for each column of a table.

### normalisation Goals: Suppose we have a db scheme: is it good? define precise notions of the qualities of a relational database scheme

Goals: Suppose we have a db scheme: is it good? Suppose we have a db scheme derived from an ER diagram: is it good? define precise notions of the qualities of a relational database scheme define algorithms

### Chapter 7: Relational Database Design

Chapter 7: Relational Database Design Database System Concepts, 5th Ed. See www.db book.com for conditions on re use Chapter 7: Relational Database Design Features of Good Relational Design Atomic Domains

### Exercise 1: Relational Model

Exercise 1: Relational Model 1. Consider the relational database of next relational schema with 3 relations. What are the best possible primary keys in each relation? employ(person_name, street, city)

### Functional Dependencies and Finding a Minimal Cover

Functional Dependencies and Finding a Minimal Cover Robert Soulé 1 Normalization An anomaly occurs in a database when you can update, insert, or delete data, and get undesired side-effects. These side

### Relational Database Design: FD s & BCNF

CS145 Lecture Notes #5 Relational Database Design: FD s & BCNF Motivation Automatic translation from E/R or ODL may not produce the best relational design possible Sometimes database designers like to

### Normalization in Database Design

in Database Design Marek Rychly mrychly@strathmore.edu Strathmore University, @ilabafrica & Brno University of Technology, Faculty of Information Technology Advanced Databases and Enterprise Systems 14

### Introduction to normalization. Introduction to normalization

Introduction to normalization Lecture 4 Instructor Anna Sidorova Agenda Presentation Review of relational models, in class exersise Introduction to normalization In-class exercises Discussion of HW2 1

### Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases

Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 15 Outline Informal Design Guidelines

### CS143 Notes: Normalization Theory

CS143 Notes: Normalization Theory Book Chapters (4th) Chapters 7.1-6, 7.8, 7.10 (5th) Chapters 7.1-6, 7.8 (6th) Chapters 8.1-6, 8.8 INTRODUCTION Main question How do we design good tables for a relational

### Unique column combinations

Unique column combinations Arvid Heise Guest lecture in Data Profiling and Data Cleansing Prof. Dr. Felix Naumann Agenda 2 Introduction and problem statement Unique column combinations Exponential search

### Data Analysis 1. SET08104 Database Systems. Copyright @ Napier University

Data Analysis 1 SET08104 Database Systems Copyright @ Napier University Entity Relationship Modelling Overview Database Analysis Life Cycle Components of an Entity Relationship Diagram What is a relationship?

### Chapter 8. Database Design II: Relational Normalization Theory

Chapter 8 Database Design II: Relational Normalization Theory The E-R approach is a good way to start dealing with the complexity of modeling a real-world enterprise. However, it is only a set of guidelines

### Relational Database Design

Relational Database Design To generate a set of relation schemas that allows - to store information without unnecessary redundancy - to retrieve desired information easily Approach - design schema in appropriate

### Fundamentals of Database System

Fundamentals of Database System Chapter 4 Normalization Fundamentals of Database Systems (Chapter 4) Page 1 Introduction To Normalization In general, the goal of a relational database design is to generate

### COMP 378 Database Systems Notes for Chapter 7 of Database System Concepts Database Design and the Entity-Relationship Model

COMP 378 Database Systems Notes for Chapter 7 of Database System Concepts Database Design and the Entity-Relationship Model The entity-relationship (E-R) model is a a data model in which information stored

### Week 11: Normal Forms. Logical Database Design. Normal Forms and Normalization. Examples of Redundancy

Week 11: Normal Forms Database Design Database Redundancies and Anomalies Functional Dependencies Entailment, Closure and Equivalence Lossless Decompositions The Third Normal Form (3NF) The Boyce-Codd

### Schema Refinement and Normalization

Schema Refinement and Normalization Module 5, Lectures 3 and 4 Database Management Systems, R. Ramakrishnan 1 The Evils of Redundancy Redundancy is at the root of several problems associated with relational

### Chapter 9: Normalization

Chapter 9: Normalization Part 1: A Simple Example Part 2: Another Example & The Formal Stuff A Problem: Keeping Track of Invoices (cont d) Suppose we have some invoices that we may or may not want to refer

### Database design theory, Part I

Database design theory, Part I Functional dependencies Introduction As we saw in the last segment, designing a good database is a non trivial matter. The E/R model gives a useful rapid prototyping tool,

### Database Management Systems. Redundancy and Other Problems. Redundancy

Database Management Systems Winter 2004 CMPUT 391: Database Design Theory or Relational Normalization Theory Dr. Osmar R. Zaïane Lecture 2 Limitations of Relational Database Designs Provides a set of guidelines,

### Functional Dependency and Normalization for Relational Databases

Functional Dependency and Normalization for Relational Databases Introduction: Relational database design ultimately produces a set of relations. The implicit goals of the design activity are: information

### 2. Conceptual Modeling using the Entity-Relationship Model

ECS-165A WQ 11 15 Contents 2. Conceptual Modeling using the Entity-Relationship Model Basic concepts: entities and entity types, attributes and keys, relationships and relationship types Entity-Relationship

### Schema Refinement, Functional Dependencies, Normalization

Schema Refinement, Functional Dependencies, Normalization MSCI 346: Database Systems Güneş Aluç, University of Waterloo Spring 2015 MSCI 346: Database Systems Chapter 19 1 / 42 Outline 1 Introduction Design

### Lecture 2 Normalization

MIT 533 ระบบฐานข อม ล 2 Lecture 2 Normalization Walailuk University Lecture 2: Normalization 1 Objectives The purpose of normalization The identification of various types of update anomalies The concept

### CS 377 Database Systems. Database Design Theory and Normalization. Li Xiong Department of Mathematics and Computer Science Emory University

CS 377 Database Systems Database Design Theory and Normalization Li Xiong Department of Mathematics and Computer Science Emory University 1 Relational database design So far Conceptual database design

### Chapter 10. Functional Dependencies and Normalization for Relational Databases

Chapter 10 Functional Dependencies and Normalization for Relational Databases Chapter Outline 1 Informal Design Guidelines for Relational Databases 1.1Semantics of the Relation Attributes 1.2 Redundant

### Limitations of E-R Designs. Relational Normalization Theory. Redundancy and Other Problems. Redundancy. Anomalies. Example

Limitations of E-R Designs Relational Normalization Theory Chapter 6 Provides a set of guidelines, does not result in a unique database schema Does not provide a way of evaluating alternative schemas Normalization

### Unit 2.1. Data Analysis 1 - V2.0 1. Data Analysis 1. Dr Gordon Russell, Copyright @ Napier University

Data Analysis 1 Unit 2.1 Data Analysis 1 - V2.0 1 Entity Relationship Modelling Overview Database Analysis Life Cycle Components of an Entity Relationship Diagram What is a relationship? Entities, attributes,

### BİL 354 Veritabanı Sistemleri. Entity-Relationship Model

BİL 354 Veritabanı Sistemleri Entity-Relationship Model Steps in building a DB application Pick application domain Conceptual design How can I describe that data? What data do I need for my application

### Foundations of Information Management

Foundations of Information Management - WS 2012/13 - Juniorprofessor Alexander Markowetz Bonn Aachen International Center for Information Technology (B-IT) Data & Databases Data: Simple information Database:

### DATABASE NORMALIZATION

DATABASE NORMALIZATION Normalization: process of efficiently organizing data in the DB. RELATIONS (attributes grouped together) Accurate representation of data, relationships and constraints. Goal: - Eliminate

### Introduction to Databases

Introduction to Databases IT University of Copenhagen January 7, 2005 This exam consists of 6 problems with a total of 16 questions. The weight of each problem is stated. You have 4 hours to answer all

### Database Management System

UNIT -6 Database Design Informal Design Guidelines for Relation Schemas; Functional Dependencies; Normal Forms Based on Primary Keys; General Definitions of Second and Third Normal Forms; Boyce-Codd Normal

### Logical Schema Design: The Relational Data Model

Logical Schema Design: The Relational Data Model Basics of the Relational Model From Conceptual to Logical Schema Logical Schema Design Select data model Hierarchical data model: hierarchies of record

### Normal forms and normalization

Normal forms and normalization An example of normalization using normal forms We assume we have an enterprise that buys products from different supplying companies, and we would like to keep track of our

### COSC344 Database Theory and Applications. Lecture 9 Normalisation. COSC344 Lecture 9 1

COSC344 Database Theory and Applications Lecture 9 Normalisation COSC344 Lecture 9 1 Overview Last Lecture Functional Dependencies This Lecture Normalisation Introduction 1NF 2NF 3NF BCNF Source: Section

### Schema Design and Normal Forms Sid Name Level Rating Wage Hours

Entity-Relationship Diagram Schema Design and Sid Name Level Rating Wage Hours Database Management Systems, 2 nd Edition. R. Ramakrishnan and J. Gehrke 1 Database Management Systems, 2 nd Edition. R. Ramakrishnan

### Lecture 6. SQL, Logical DB Design

Lecture 6 SQL, Logical DB Design Relational Query Languages A major strength of the relational model: supports simple, powerful querying of data. Queries can be written intuitively, and the DBMS is responsible

### Designing a Database Schema

Week 10: Database Design Database Design From an ER Schema to a Relational One Restructuring an ER schema Performance Analysis Analysis of Redundancies, Removing Generalizations Translation into a Relational

### C# Cname Ccity.. P1# Date1 Qnt1 P2# Date2 P9# Date9 1 Codd London.. 1 21.01 20 2 23.01 2 Martin Paris.. 1 26.10 25 3 Deen London.. 2 29.

4. Normalisation 4.1 Introduction Suppose we are now given the task of designing and creating a database. How do we produce a good design? What relations should we have in the database? What attributes

### Database Design and Normal Forms

Database Design and Normal Forms Database Design coming up with a good schema is very important How do we characterize the goodness of a schema? If two or more alternative schemas are available how do

### The University of British Columbia

The University of British Columbia Computer Science 304 Midterm Examination October 31, 2005 Time: 50 minutes Total marks: 50 Instructor: Rachel Pottinger Name ANSWER KEY (PRINT) (Last) (First) Signature

### Why Is This Important? Schema Refinement and Normal Forms. The Evils of Redundancy. Functional Dependencies (FDs) Example (Contd.)

Why Is This Important? Schema Refinement and Normal Forms Chapter 19 Many ways to model a given scenario in a database How do we find the best one? We will discuss objective criteria for evaluating database

### Database Design. Marta Jakubowska-Sobczak IT/ADC based on slides prepared by Paula Figueiredo, IT/DB

Marta Jakubowska-Sobczak IT/ADC based on slides prepared by Paula Figueiredo, IT/DB Outline Database concepts Conceptual Design Logical Design Communicating with the RDBMS 2 Some concepts Database: an

### Answer Key. UNIVERSITY OF CALIFORNIA College of Engineering Department of EECS, Computer Science Division

Answer Key UNIVERSITY OF CALIFORNIA College of Engineering Department of EECS, Computer Science Division CS186 Fall 2003 Eben Haber Midterm Midterm Exam: Introduction to Database Systems This exam has

### Question 1. Relational Data Model [17 marks] Question 2. SQL and Relational Algebra [31 marks]

EXAMINATIONS 2005 MID-YEAR COMP 302 Database Systems Time allowed: Instructions: 3 Hours Answer all questions. Make sure that your answers are clear and to the point. Write your answers in the spaces provided.

### Normalization. Purpose of normalization Data redundancy Update anomalies Functional dependency Process of normalization

Normalization Purpose of normalization Data redundancy Update anomalies Functional dependency Process of normalization 1 Purpose of Normalization Normalization is a technique for producing a set of suitable

### Theory of Relational Database Design and Normalization

Theory of Relational Database Design and Normalization (Based on Chapter 14 and some part of Chapter 15 in Fundamentals of Database Systems by Elmasri and Navathe, Ed. 3) 1 Informal Design Guidelines for

### SAMPLE FINAL EXAMINATION SPRING SESSION 2015

SAMPLE FINAL EXAMINATION SPRING SESSION 2015 School of Computing, Engineering and Mathematics Student family name: Student given name/s: Student ID number: Course: Unit Name (In Full): Database Design

### Chapter 10. Functional Dependencies and Normalization for Relational Databases. Copyright 2007 Ramez Elmasri and Shamkant B.

Chapter 10 Functional Dependencies and Normalization for Relational Databases Copyright 2007 Ramez Elmasri and Shamkant B. Navathe Chapter Outline 1 Informal Design Guidelines for Relational Databases

### ER modelling, Weak Entities, Class Hierarchies, Aggregation

CS344 Database Management Systems ER modelling, Weak Entities, Class Hierarchies, Aggregation Aug 2 nd - Lecture Notes (Summary) Submitted by - N. Vishnu Teja Saurabh Saxena 09010125 09010145 (Most the

### Requirement Analysis & Conceptual Database Design. Problem analysis Entity Relationship notation Integrity constraints Generalization

Requirement Analysis & Conceptual Database Design Problem analysis Entity Relationship notation Integrity constraints Generalization Introduction: Lifecycle Requirement analysis -> Text Conceptual Design

### CMU - SCS 15-415/15-615 Database Applications Spring 2013, C. Faloutsos Homework 1: E.R. + Formal Q.L. Deadline: 1:30pm on Tuesday, 2/5/2013

CMU - SCS 15-415/15-615 Database Applications Spring 2013, C. Faloutsos Homework 1: E.R. + Formal Q.L. Deadline: 1:30pm on Tuesday, 2/5/2013 Reminders - IMPORTANT: Like all homeworks, it has to be done

### Boyce-Codd Normal Form

4NF Boyce-Codd Normal Form A relation schema R is in BCNF if for all functional dependencies in F + of the form α β at least one of the following holds α β is trivial (i.e., β α) α is a superkey for R

### DATABASE DESIGN. - Developing database and information systems is performed using a development lifecycle, which consists of a series of steps.

DATABASE DESIGN - The ability to design databases and associated applications is critical to the success of the modern enterprise. - Database design requires understanding both the operational and business

### Jordan University of Science & Technology Computer Science Department CS 728: Advanced Database Systems Midterm Exam First 2009/2010

Jordan University of Science & Technology Computer Science Department CS 728: Advanced Database Systems Midterm Exam First 2009/2010 Student Name: ID: Part 1: Multiple-Choice Questions (17 questions, 1

### The Relational Model. Why Study the Relational Model? Relational Database: Definitions

The Relational Model Database Management Systems, R. Ramakrishnan and J. Gehrke 1 Why Study the Relational Model? Most widely used model. Vendors: IBM, Microsoft, Oracle, Sybase, etc. Legacy systems in

Winter 2011 CSE-3421 Exercises w/ answers p. 1 of 28 CSE-3421: Exercises with answers 1. Independence Answer #1.2 (page 23) from the textbook: What is logical data independence and why is it important?

### Chapter 2: Entity-Relationship Model. Entity Sets. " Example: specific person, company, event, plant

Chapter 2: Entity-Relationship Model! Entity Sets! Relationship Sets! Design Issues! Mapping Constraints! Keys! E-R Diagram! Extended E-R Features! Design of an E-R Database Schema! Reduction of an E-R

### Conceptual Design Using the Entity-Relationship (ER) Model

Conceptual Design Using the Entity-Relationship (ER) Model Module 5, Lectures 1 and 2 Database Management Systems, R. Ramakrishnan 1 Overview of Database Design Conceptual design: (ER Model is used at

### Database Constraints and Design

Database Constraints and Design We know that databases are often required to satisfy some integrity constraints. The most common ones are functional and inclusion dependencies. We ll study properties of

### Chapter 2: Entity-Relationship Model. E-R R Diagrams

Chapter 2: Entity-Relationship Model What s the use of the E-R model? Entity Sets Relationship Sets Design Issues Mapping Constraints Keys E-R Diagram Extended E-R Features Design of an E-R Database Schema

### Theory behind Normalization & DB Design. Satisfiability: Does an FD hold? Lecture 12

Theory behind Normalization & DB Design Lecture 12 Satisfiability: Does an FD hold? Satisfiability of FDs Given: FD X Y and relation R Output: Does R satisfy X Y? Algorithm: a.sort R on X b.do all the

### Limitations of DB Design Processes

Normalization CS 317/387 1 Limitations of DB Design Processes Provides a set of guidelines, does not result in a unique database schema Does not provide a way of evaluating alternative schemas Pitfalls:

### The Relational Model. Ramakrishnan&Gehrke, Chapter 3 CS4320 1

The Relational Model Ramakrishnan&Gehrke, Chapter 3 CS4320 1 Why Study the Relational Model? Most widely used model. Vendors: IBM, Informix, Microsoft, Oracle, Sybase, etc. Legacy systems in older models

### Database Design Methodology

Topic 7 Database Design Methodology LEARNING OUTCOMES When you have completed this Topic you should be able to: 1. Discuss the purpose of a design methodology. 2. Explain three main phases of design methodology.

### BCA. Database Management System

BCA IV Sem Database Management System Multiple choice questions 1. A Database Management System (DBMS) is A. Collection of interrelated data B. Collection of programs to access data C. Collection of data

### CSCI-GA.2433-001 Database Systems Lecture 7: Schema Refinement and Normalization

CSCI-GA.2433-001 Database Systems Lecture 7: Schema Refinement and Normalization Mohamed Zahran (aka Z) mzahran@cs.nyu.edu http://www.mzahran.com View 1 View 2 View 3 Conceptual Schema At that point we

### 3. Relational Model and Relational Algebra

ECS-165A WQ 11 36 3. Relational Model and Relational Algebra Contents Fundamental Concepts of the Relational Model Integrity Constraints Translation ER schema Relational Database Schema Relational Algebra

### IV. The (Extended) Entity-Relationship Model

IV. The (Extended) Entity-Relationship Model The Extended Entity-Relationship (EER) Model Entities, Relationships and Attributes Cardinalities, Identifiers and Generalization Documentation of EER Diagrams

### Announcements. SQL is hot! Facebook. Goal. Database Design Process. IT420: Database Management and Organization. Normalization (Chapter 3)

Announcements IT0: Database Management and Organization Normalization (Chapter 3) Department coin design contest deadline - February -week exam Monday, February 1 Lab SQL SQL Server: ALTER TABLE tname

### Normalisation. Why normalise? To improve (simplify) database design in order to. Avoid update problems Avoid redundancy Simplify update operations

Normalisation Why normalise? To improve (simplify) database design in order to Avoid update problems Avoid redundancy Simplify update operations 1 Example ( the practical difference between a first normal

### DATABASE MANAGEMENT SYSTEMS. Question Bank:

DATABASE MANAGEMENT SYSTEMS Question Bank: UNIT 1 1. Define Database? 2. What is a DBMS? 3. What is the need for database systems? 4. Define tupule? 5. What are the responsibilities of DBA? 6. Define schema?

### Normalization. Normalization. Normalization. Data Redundancy

Normalization Normalization o Main objective in developing a logical data model for relational database systems is to create an accurate representation of the data, its relationships, and constraints.

### Introduction to Database Systems. Normalization

Introduction to Database Systems Normalization Werner Nutt 1 Normalization 1. Anomalies 1. Anomalies 2. Boyce-Codd Normal Form 3. 3 rd Normal Form 2 Anomalies The goal of relational schema design is to

### Chapter 5: Logical Database Design and the Relational Model Part 2: Normalization. Introduction to Normalization. Normal Forms.

Chapter 5: Logical Database Design and the Relational Model Part 2: Normalization Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B. Prescott, Fred R. McFadden Robert C. Nickerson ISYS

### Once the schema has been designed, it can be implemented in the RDBMS.

2. Creating a database Designing the database schema... 1 Representing Classes, Attributes and Objects... 2 Data types... 5 Additional constraints... 6 Choosing the right fields... 7 Implementing a table

### SQL DATA DEFINITION: KEY CONSTRAINTS. CS121: Introduction to Relational Database Systems Fall 2015 Lecture 7

SQL DATA DEFINITION: KEY CONSTRAINTS CS121: Introduction to Relational Database Systems Fall 2015 Lecture 7 Data Definition 2 Covered most of SQL data manipulation operations Continue exploration of SQL

### 7.1 The Information system

Chapter 7. Database Planning, Design and Administration Last few decades have seen proliferation of software applications, many requiring constant maintenance involving: correcting faults, implementing

### RELATIONAL DATABASE DESIGN

RELATIONAL DATABASE DESIGN g Good database design - Avoiding anomalies g Functional Dependencies g Normalization & Decomposition Using Functional Dependencies g 1NF - Atomic Domains and First Normal Form

### Outline. Data Modeling. Conceptual Design. ER Model Basics: Entities. ER Model Basics: Relationships. Ternary Relationships. Yanlei Diao UMass Amherst

Outline Data Modeling Yanlei Diao UMass Amherst v Conceptual Design: ER Model v Relational Model v Logical Design: from ER to Relational Slides Courtesy of R. Ramakrishnan and J. Gehrke 1 2 Conceptual

### LAB 3: Introduction to Domain Modeling and Class Diagram

LAB 3: Introduction to Domain Modeling and Class Diagram OBJECTIVES Use the UML notation to represent classes and their properties. Perform domain analysis to develop domain class models. Model the structural

### MCQs~Databases~Relational Model and Normalization http://en.wikipedia.org/wiki/database_normalization

http://en.wikipedia.org/wiki/database_normalization Database normalization is the process of organizing the fields and tables of a relational database to minimize redundancy. Normalization usually involves

### Boolean Algebra (cont d) UNIT 3 BOOLEAN ALGEBRA (CONT D) Guidelines for Multiplying Out and Factoring. Objectives. Iris Hui-Ru Jiang Spring 2010

Boolean Algebra (cont d) 2 Contents Multiplying out and factoring expressions Exclusive-OR and Exclusive-NOR operations The consensus theorem Summary of algebraic simplification Proving validity of an

### Chapter 5: FUNCTIONAL DEPENDENCIES AND NORMALIZATION FOR RELATIONAL DATABASES

1 Chapter 5: FUNCTIONAL DEPENDENCIES AND NORMALIZATION FOR RELATIONAL DATABASES INFORMAL DESIGN GUIDELINES FOR RELATION SCHEMAS We discuss four informal measures of quality for relation schema design in

### 6.830 Lecture 3 9.16.2015 PS1 Due Next Time (Tuesday!) Lab 1 Out today start early! Relational Model Continued, and Schema Design and Normalization

6.830 Lecture 3 9.16.2015 PS1 Due Next Time (Tuesday!) Lab 1 Out today start early! Relational Model Continued, and Schema Design and Normalization Animals(name,age,species,cageno,keptby,feedtime) Keeper(id,name)