Tài liệu SQL: Practical Guide for Developers docx

266 378 0
Tài liệu SQL: Practical Guide for Developers docx

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

[...]... suggestions for improvement of any aspect of this book You can send feedback via the book’s Web site (http://www.mkp.com /practical/ sql), or you can send us an email to the addresses below Michael J Donahoo Jeff_Donahoo@baylor.edu Gregory D Speegle Greg_Speegle@baylor.edu SQL: Practical Guide for Developers chapter 1 Databasics A database is a repository designed for organizing and accessing information For. .. same row in the parent (vendors) table If a foreign key is declared, the DBMS will enforce the foreign key integrity constraint by never allowing the existence of a violating row in the child table Like the primary key, a foreign key may have multiple attributes Foreign keys can even refer to attributes in the same table For example, vendors.referredby is a foreign key to vendors.vendorid (see Figure... attribute For example, each fruit salad has 10 grapes and 5 watermelon cubes The primary key for madewith consists of two attributes: itemid and ingredientid As you might suspect, madewith.ingredientid is a foreign key referencing ingredients.ingredientid, and madewith.itemid is a foreign key referencing items.itemid Given these primary and foreign keys, the DBMS will enforce the following constraints for. .. example A foreign key depends on the row it is referencing in another table for completeness In the ingredients table, a vendorid attribute value makes little sense without a corresponding row in the vendors table For example, the vendorid for Cheese in ingredients is DNDRY, which has little meaning unless we can find out information about the vendor with that identifier The table containing the foreign... will not match 'Bob ' ■ 1.2 Data Types 5 The default character set for your DBMS may be limited in the kinds of characters it can represent For example, if your DBMS uses the ASCII (American Standard Code for Information Interchange) character encoding, it can only represent English characters Unfortunately, this doesn’t work well for internationalization The national character string type can represent... identifier and enforce its special meaning To avoid these difficulties, relational databases provide a special value, called NULL, indicating that a field’s value is unknown In the vendors table, referredby is NULL for all vendors where we do not have a recommending vendor Unless explicitly forbidden, NULL is a valid value for a column of any data type For example, NULL is a valid value for a column of... exactly The specifics of a particular DBMS can be found in its documentation There are many reasons a DBMS may vary from the standard, including performance, legacy, or marketing Fortunately, the basic syntax of SQL is the same for all DBMS See the book Web site for information on DBMS-specific syntax SQL is divided into three major parts Data manipulation language (DML) is used to store and retrieve data from... _ 1 2 Chapter 1: Databasics ■ Basic lists may work for very simple databases However, the limitations of this approach can make even simple tasks difficult Let’s look at our address book example again One problem is that it has space for information we don’t know/need (e.g., home address), whereas it does not have space for information we need to know (e.g., pager number) Searching presents... time information, or both Type Stores Literal DATE TIME year, month, day hour, minute, and second DATE 'YYYY-MM-DD' TIME 'HH:MM:SS' TIMESTAMP year, month, day, hour, minute, and second TIMESTAMP 'YYYY-MM-DD HH:MM:SS' Seconds may contain fractional values (e.g., 32.456 seconds) An optional precision for fractional seconds may be given for TIME and TIMESTAMP TIME and TIMESTAMP may include time zone information... querying information grows Lucky for us, computers are especially adept at managing and quickly accessing information Software designed to store, manipulate, and retrieve data in a database is called a Database management system (DBMS) Here, we focus exclusively on a specific (and by far the most common) type of DBMS, the relational DBMS There are many relational DBMSs (see the book Web site for pointers . Dartmouth SQL: Practical Guide for Developers The Morgan Kaufmann Practical Guides Series Series Editor, Michael J. Donahoo SQL: Practical Guide for Developers Michael. Weiss JSP: Practical Guide for Java Programmers Robert J. Brunner JSTL: Practical Guide for JSP Programmers Sue Spielman Java: Practical Guide for Programmers Zbigniew

Ngày đăng: 13/02/2014, 08:20

Tài liệu cùng người dùng

Tài liệu liên quan