NJIT CS 103 - Introduction to Database Concepts

Unformatted text preview:

Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-WesleyFluency with Information TechnologyThird Editionby Lawrence SnyderChapter 16: A Table with a View:Introduction to Database Concepts16-21-2Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-WesleyDifferences Between Tables and Databases• When we think of databases, we often think of tables of information• Comparing Tables– Database tables• Metadata tag identifying each of the data fields– Spreadsheet tables• Rely on position to keep the integrity of their data– HTML tables• Data as table entries with no unique identity at all• Concerned only with how to display the data, not with its meaning16-31-3Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-WesleyThe Database's Advantage• Metadata is key advantage of databases over other systems recording data as tables• Two of the most important roles in defining metadata– Identify the type of data with a unique tag– Define the affinity of the data16-41-4Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-WesleyXML: A Language for Metadata Tags• Extensible Markup Language– Tagging scheme similar to HTML– No standard tags to learn• Self-describing, think up the tags you need– Works well with browsers and Web-based applications– Use a simple text editor– XML tag names cannot contain spaces16-51-5Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-WesleyAn Example from Tahiti• Area in km2for Tahiti & neighboring islands16-61-6Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-WesleyAn Example from Tahiti (cont'd)• First line<?xml version="1.0" encoding="ISO-8859-1" ?>• File should be ASCII text• File extension should be .xml16-71-7Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley16-81-8Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-WesleyExpanding the Use of XML• Combine encodings of two archipelagos –the Windward and the Galapagos Islands• Root element is the tag that encloses all of the content of the XML file– <archipelago> in Fig. 16.1– <geo_feature> in Fig. 16.2• Indenting for readability and structure16-91-9Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley16-101-10Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-WesleyAttributes in XML• Use attributes for additional metadata, not for additional content– Not good, name is content:<archipelago name="Galapagos">– Better to give alternate form of the data<a_name accents="Gal&aacute;pagos">Galapagos</a_name>16-111-11Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-WesleyEffective Design with XML Tags• Identification Rule: Label Data with Tags Consistently– You can choose whatever tag names you with to name data, but once you've decided on a tag for a particular kind of data, you must always surround it with that tag.16-121-12Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-WesleyEffective Design with XML Tags (cont'd)• Affinity Rule: Group Related Data– Enclose in a pair of tags all tagged data referring to the same entity. Grouping it keeps it all together, but the idea is much more fundamental: Grouping makes an association of the tagged data items as being related to each other, properties of the same thing.– Groups together data for a single thing – an island• Association is among properties of an object16-131-13Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-WesleyEffective Design with XML Tags (cont'd)• Collection Rule: Group Related Instances– When you have several instances of the same kind of data, enclose them in tags; again, it keeps them together and implies that they are related by being instances of the same type.– Groups together data of several instance of the same thing – islands• Association is among the objects themselves (entities)16-141-14Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-WesleyThe XML Tree• XML encodings of information produce hierarchical descriptions that can be thought of as trees– Hierarchy a consequence of how tags enclose one another and the data16-151-15Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley16-161-16Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-WesleyTables and Entities• A relational database describes the relationships among different kinds of data– Allows the software to answer queries about them16-171-17Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-WesleyEntities• Anything that can de identified by a fixed number of its characteristics (attributes)– Attributes have names and values– The values are the data that's stored in the table• An entity defines a table– Name of the entity is the name of the table– Each attribute is assigned a column with column heading being the attribute name16-181-18Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley16-191-19Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-WesleyEntities (cont'd)• Entity instances– Rows of data• Table instance– Any table containing specific rows• Data type– Defines the form of the information that can be stored in a field• Number, text, image, …<name type="text"> <area type="number">16-201-20Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-WesleyProperties of Entities• A relational database table can be empty• Instances Are Unordered– Order of the rows and columns does not matter in databases– Freedom to move the data is limited to exchanging entire rows or exchanging entire columns16-211-21Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-WesleyProperties of Entities (cont'd)• Uniqueness– No two rows can be the same– Two rows can have the same value for some attributes, just not all attributes16-221-22Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-WesleyProperties Of Entities (cont'd)• Keys– Any set of attributes for which all attributes are different is called a candidate key– Pick one and call it the primary key to decide uniqueness– Key must distinguish all potential and actual entities, not just those that happen to be in the table at a given time– If


View Full Document
Download Introduction to Database Concepts
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Introduction to Database Concepts and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Introduction to Database Concepts 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?