Docsity

Multivalue, Multicolumn Data and Inconsistent Values | CSIS 350, Study notes of Database Management Systems (DBMS)

Toggle sidebar
bg1
CSIS 350 โ€“ Lecture 13
Read: Chapter 5: 119 โ€“ 135
Discuss Multivalued dependencies
Chapter 4:
Last time we started looking at some of the issues surrounding database design when we
start with a set of tables. Major Question: Are there problems with the data?
- Unsatisfied referential Integrity constraints (we looked at this last time)
- Multicolumn data
- Inconsistent values
- Missing values
- "comment" columns
Multivalue, Multicolumn data
Sometimes you will find tables where multiple columns are used for the different values
of the same type of data. For example,
Book( Title, Publisher, Author1, Author2, Author3,
NumPages, ISBN )
This problem is commonly associated with data that is not from a database, but is from
another source such as a spreadsheet.
What problems are associated with organizing data this way?
1) Limits amount of data that can be stored โ€“ what if you need to store more values
than you have columns?
2) Makes queries more complex. How do I find all books written by 'Gretchen
Hansen'?
How do you fix it?
Move multiple column data into a separate table:
Book( Title, Publisher, NumPages, ISBN )
Author( BookTitle, AuthorName )
Where Author.BookTitle must exist in Book.Title
Now how do I find all the books written by Gretchen Hansen?
Note that this is very similar to the Multivalue dependency problems we saw earlier.
pf3
pf4

Partial preview of the text

Download Multivalue, Multicolumn Data and Inconsistent Values | CSIS 350 and more Study notes Database Management Systems (DBMS) in PDF only on Docsity!

CSIS 350 โ€“ Lecture 13

Read: Chapter 5: 119 โ€“ 135 Discuss Multivalued dependencies Chapter 4: Last time we started looking at some of the issues surrounding database design when we start with a set of tables. Major Question: Are there problems with the data?

  • Unsatisfied referential Integrity constraints (we looked at this last time)
  • Multicolumn data
  • Inconsistent values
  • Missing values
  • "comment" columns Multivalue, Multicolumn data Sometimes you will find tables where multiple columns are used for the different values of the same type of data. For example, Book( Title, Publisher, Author1, Author2, Author3, NumPages, ISBN ) This problem is commonly associated with data that is not from a database, but is from another source such as a spreadsheet. What problems are associated with organizing data this way?
  1. Limits amount of data that can be stored โ€“ what if you need to store more values than you have columns?
  2. Makes queries more complex. How do I find all books written by 'Gretchen Hansen'? How do you fix it? Move multiple column data into a separate table: Book( Title, Publisher, NumPages, ISBN ) Author( BookTitle, AuthorName ) Where Author.BookTitle must exist in Book.Title Now how do I find all the books written by Gretchen Hansen? Note that this is very similar to the Multivalue dependency problems we saw earlier.

Inconsistent values This is a serious problem when creating a DB from existing data.

  • Data coded differently o Gretchen Hansen or Hansen, Gretchen o 'Database Processing' or 'Database Processing: Fundamentals, Design, and Implementation'
  • Data misspelled o 'Database Procesing' Especially likely if merging data from multiple sources. A real problem for primary and foreign key columns. Why? How can we detect this? Well, there are a couple of approaches:
  1. Use a NOT IN subquery like we did last time to find unsatisfied integrity constraints: Select BookTitle from Author where BookTitle NOT IN (Select Title From Book);
  2. Use Grouping Select AuthorName, count() from Author group by AuthorName; If you have a lot of data, and you expect the groups to be fairly large, you can use a Having clause to limit the number of rows displayed. Select StarshipName, count() from CrewMember group by StarshipName having count(*) < 3; [Lists all starships with less than 3 crew members] Missing Values A missing value (or a null value) occurs when data has not been supplied for a column. [Note that this is not the same a blank value.] This can happen for several reasons:
  3. It does not make sense for the column to contain data in this particular row, so it is left null.
  4. It could mean that the value is unknown.
  5. It could mean that the value is known, but unrecorded.

Same type of data recorded in multiple ways Multiple kinds of data in a single column We'd like to have the following in our database

  • Budget
  • NumberAdults
  • NumberChildren
  • Bedrooms
  • DwellingType Extracting this data from the comments is going to be very time consuming and laborious. There is no good way to automate this. In-class exercise Exercises 4.28 โ€“ 4.