TAILIEUCHUNG - Joe Celko s SQL for Smarties - Advanced SQL Programming P7

Joe Celko s SQL for Smarties - Advanced SQL Programming P7. In the SQL database community, Joe Celko is a well-known columnist and purveyor of valuable insights. In Joe Celko's SQL for Smarties: Advanced SQL Programming, he picks up where basic SQL training and experience leaves many database professionals and offers tips, techniques, and explanations that help readers extend their capabilities to top-tier SQL programming. Although Celko denies that the book is about database theory, he nevertheless alludes to theory often to buttress his practical points. This title is not for novices, as the author points out. Instead, its intended audience. | 32 CHAPTER 1 DATABASE DESIGN they should be one table with a column for a sex code. I would have split a table on sex. This is very obvious but it can also be subtler. Consider a subscription database that has both organizational and individual subscribers. There are two tables with the same structure and a third table that holds the split attribute subscription type. CREATE TABLE OrgSubscriptions subscr_id INTEGER NOT NULL PRIMARY KEY REFERENCES SubscriptionTypes subscr_id org_name CHAR 35 last_name CHAR 15 first_name CHAR 15 address1 CHAR 35 NOT NULL . CREATE TABLE IndSubscriptions subscr_id INTEGER NOT NULL PRIMARY KEY REFERENCES SubscriptionTypes subscr_id org_name CHAR 35 last_name CHAR 15 first_name CHAR 15 address1 CHAR 35 NOT NULL . CREATE TABLE SubscriptionTypes subscr_id INTEGER NOT NULL PRIMARY KEY subscr_type CHAR 1 DEFAULT I NOT NULL CHECK subscr_type IN I O An organizational subscription can go to just a person last_name first_name or just the organization name org_name or both. If an individual subscription has no particular person it is sent to an organization called Current Resident instead. The original specifications enforce a condition that subscr_id be universally unique in the schema. The first step is to replace the three tables with one table for all subscriptions and move the subscription type back into a column of its own since it is an attribute of a subscription. Next we need to add constraints to deal with the constraints on each subscription. Schema and Table Creation 33 CREATE TABLE Subscriptions subscr_id INTEGER NOT NULL PRIMARY KEY REFERENCES SubscriptionTypes subscr_id org_name CHAR 35 DEFAULT Current Resident last_name CHAR 15 first_name CHAR 15 subscr_type CHAR 1 DEFAULT I NOT NULL CHECK subscr_type IN I O CONSTRAINT known_addressee CHECK COALESCE org_name first_name last_name IS NOT NULL CONSTRAINT junkmail CHECK CASE WHEN subscr_type I AND org_name Current Resident THEN 1 WHEN subscr_type O AND org_name Current Resident .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.