[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"doc-seo-656116-105":3,"detail-sidebar-cat-0-en-105":81,"doc-detail-656116-en":130},{"code":4,"msg":5,"data":6},0,"ok",{"site_id":7,"language":8,"slug":9,"title":10,"keywords":11,"description":12,"schema_data":13,"social_meta":74,"head_meta":76,"extra_data":78,"updated_unix":80},105,"en","applied-databases-handout-2-database-design","Applied Databases - Handout 2 - Database Design","","Handout 2 on Database Design explains core principles of relational modeling using SQL examples. It introduces key constraints and inclusion constraints, showing how key definition and update rejection preserve integrity. It then demonstrates foreign key constraints via CREATE TABLE statements. The handout also covers schema modification using DROP and ALTER commands, highlights cautions in conceptual modeling and entity-relationship (ER) diagrams, and outlines conceptual design steps and mapping ER models into relational schemas.",{"@graph":14,"@context":73},[15,34,56],{"@type":16,"itemListElement":17},"BreadcrumbList",[18,23,27,31],{"item":19,"name":20,"@type":21,"position":22},"https://docshare.wps.com","Home","ListItem",1,{"item":24,"name":25,"@type":21,"position":26},"https://docshare.wps.com/document/","Document",2,{"item":28,"name":29,"@type":21,"position":30},"https://docshare.wps.com/document/technology/","Technology",3,{"item":32,"name":10,"@type":21,"position":33},"https://docshare.wps.com/document/applied-databases-handout-2-database-design/656116/",4,{"url":32,"name":10,"@type":35,"image":36,"author":41,"headline":10,"publisher":44,"fileFormat":47,"inLanguage":8,"description":12,"dateModified":48,"datePublished":49,"encodingFormat":47,"isAccessibleForFree":50,"interactionStatistic":51},"DigitalDocument",{"url":37,"@type":38,"width":39,"height":40},"https://docshare.wps.com/thumbnails/applied-databases-handout-2-database-design/656116.png","ImageObject",300,407,{"name":42,"@type":43},"8796093062539","Person",{"url":19,"name":45,"@type":46},"DocShare","Organization","application/pdf","2026-10-29","2026-10-25",true,{"@type":52,"interactionType":53,"userInteractionCount":55},"InteractionCounter",{"@type":54},"ViewAction",5,{"@type":57,"mainEntity":58},"FAQPage",[59,65,69],{"name":60,"@type":61,"acceptedAnswer":62},"What is a key constraint and why do updates violate it get rejected?","Question",{"text":63,"@type":64},"A key is a subset of attributes that uniquely identifies a tuple. Updates that would break this uniqueness property are rejected to keep the database instance valid.","Answer",{"name":66,"@type":61,"acceptedAnswer":67},"How do inclusion constraints work in relational databases?",{"text":68,"@type":64},"An inclusion constraint means a field in one table references a tuple in another relation by using its key. The referenced tuple must exist for the database to remain valid.",{"name":70,"@type":61,"acceptedAnswer":71},"What is the purpose of foreign key constraints in the handout’s examples?",{"text":72,"@type":64},"Foreign key constraints are a restricted form of inclusion constraints that enforce referential existence. The example ties Climbs to Hikers and Munros through FOREIGN KEY references.","https://schema.org",{"og:url":32,"og:type":75,"og:title":10,"og:site_name":45,"og:description":12},"article",{"robots":77,"canonical":32},"index,follow",{"doc_id":79,"site_id":7},656116,1793020081,{"code":4,"msg":82,"data":83},"success",[84,88,92,96,100,104,109,114,119,122,126],{"id":22,"doc_module":4,"doc_module_name":25,"category_name":85,"show_sort_weight":86,"slug":87},"Story & Novel",90,"story-novel",{"id":26,"doc_module":4,"doc_module_name":25,"category_name":89,"show_sort_weight":90,"slug":91},"Literature",80,"literature",{"id":33,"doc_module":4,"doc_module_name":25,"category_name":93,"show_sort_weight":94,"slug":95},"Exam",70,"exam",{"id":55,"doc_module":4,"doc_module_name":25,"category_name":97,"show_sort_weight":98,"slug":99},"Comic",60,"comic",{"id":101,"doc_module":4,"doc_module_name":25,"category_name":29,"show_sort_weight":102,"slug":103},6,50,"technology",{"id":105,"doc_module":4,"doc_module_name":25,"category_name":106,"show_sort_weight":107,"slug":108},7,"Healthcare",40,"healthcare",{"id":110,"doc_module":4,"doc_module_name":25,"category_name":111,"show_sort_weight":112,"slug":113},8,"Research & Report",30,"research-report",{"id":115,"doc_module":4,"doc_module_name":25,"category_name":116,"show_sort_weight":117,"slug":118},9,"Religion & Spirituality",20,"religion-spirituality",{"id":117,"doc_module":4,"doc_module_name":25,"category_name":120,"show_sort_weight":117,"slug":121},"World Cup","world-cup",{"id":123,"doc_module":4,"doc_module_name":25,"category_name":124,"show_sort_weight":123,"slug":125},10,"Lifestyle","lifestyle",{"id":127,"doc_module":4,"doc_module_name":25,"category_name":128,"show_sort_weight":55,"slug":129},19,"General","general",{"code":4,"msg":82,"data":131},{"doc_id":79,"user_id":132,"nickname":42,"user_avatar":11,"doc_module":4,"category_id":101,"category_name":29,"doc_title":10,"doc_description":12,"doc_content":133,"file_id":134,"file_url":135,"file_type":136,"file_size":137,"view_count":55,"is_deleted":4,"is_public":22,"is_downloadable":22,"audit_status":22,"page_count":105,"language":138,"language_code":8,"site_id":7,"html_lang":8,"table_of_contents":139,"faqs":140,"seo_title":141,"seo_description":12,"update_tm":142,"read_time":143},8796093062539,"| Applied Databases\u003Cbr>Handout 2 . Database Design.\u003Cbr>5 October 2010 |\n| --- |\n| Key Constraints\u003Cbr>A key is a subset of the attributes that uniquely identiﬁes a tuple, and for which no subset of the key has this property.\u003Cbr>CREATE TABLE Hikers ( HId INTEGER,\u003Cbr>HName CHAR(30),\u003Cbr>Skill CHAR(3),\u003Cbr>Age INTEGER,\u003Cbr>PRIMARY KEY (HId) )\u003Cbr>CREATE TABLE Climbs ( HId INTEGER,\u003Cbr>MId INTEGER,\u003Cbr>Date DATE,\u003Cbr>Time INTEGER,\u003Cbr>PRIMARY KEY (HId, MId) )\u003Cbr>Updates that violate key constraints are rejected.\u003Cbr>Do you think the key in the second example is the right choice?\u003Cbr>AD 2.2 |\n\n\n| SQL DDL\u003Cbr>In its simplest use, SQL’s Data Deﬁnition Language (DDL) provides a name and a type for each column of a table.\u003Cbr>CREATE TABLE Hikers ( HId INTEGER, HName CHAR(40), Skill CHAR(3), Age INTEGER )\u003Cbr>In addition to describing the type or a table, the DDL also allows you to impose constraints. We’ll deal with two kinds of constraints here: key constraints and inclusion constraints\u003Cbr>AD 2.1 |\n| --- |\n| Inclusion Constraints\u003Cbr>A ﬁeld in one table may refer to a tuple in another relation by indicating its key. The referenced tuple must exist in the other relation for the database instance to be valid. For example, we expect any MId value in the Climbs table to be included in the MId column of the Munros table.\u003Cbr>SQL provides a restricted form of inclusion constraint, foreign key constraints.\u003Cbr>CREATE TABLE Climbs ( HId INTEGER,\u003Cbr>MId INTEGER,\u003Cbr>Date DATE,\u003Cbr>Time INTEGER,\u003Cbr>PRIMARY KEY (HId, MId),\u003Cbr>FOREIGN KEY (HId) REFERENCES Hikers(HId), FOREIGN KEY (MId) REFERENCES Munros(MId) )\u003Cbr>AD 2.3 |\n\n\n| Schema modiﬁcation\u003Cbr>Extremely useful, because database requirements change over time. Examples\u003Cbr>1. DROP TABLE Hikers;\u003Cbr>2. DROP VIEW Mypeaks;\u003Cbr>3. ALTER TABLE Climbs ADD Weather CHAR(50);\u003Cbr>4. ALTER TABLE Munros DROP Rating;\u003Cbr>Almost all of these could violate an integrity constraint or cause a “legacy” program to fail.\u003Cbr>Only ALTER [TABLE ... ADD ...](TABLE ... ADD ... is)[ is](TABLE ... ADD ... is) usually innocuous. It is also very useful.\u003Cbr>AD 2.4 |\n| --- |\n| Conceptual Modelling – a Caution\u003Cbr>There are many tools for conceptual modelling some of them (UML, Rational Rose, etc.) are designed for the more general task of software speciﬁcation. E-R diagrams are a subclass of these, intended speciﬁcally for databases. They all have the same ﬂavour.\u003Cbr>Even within E-R diagrams, no two textbooks will agree on the details. We’ll follow R&G, but be warned that other texts will use diﬀerent convernmtions (especially in the way many-one and many-many relationships are described.)\u003Cbr>Unless you have a formal/mathematical grasp of the meaning of a diagram, conceptual modelling is almost guaranteed to end in ﬂawed designs.\u003Cbr>AD 2.6 |\n\n\n| Conceptual Modelling and Entity-Relationship Diagrams\u003Cbr>[R&G Chapter 2]\u003Cbr>Obtaining a good database design is one of the most challenging parts of building a database system. The database design speciﬁes what the users will ﬁnd in the database and how they will be able to use it.\u003Cbr>For simple databases, the task is usually trivial, but for complex databases required that serve a commercial enterprise or a scientiﬁc discipline, the task can daunting. One can ﬁnd databases with 1000 tables in them!\u003Cbr>A commonly used tool to design databases is the Entity Relationship (E-R) model. The basic idea is simple: to “conceptualize” the database by means of a diagram and then to translate that diagram into a formal database speciﬁcation (e.g. SQL DDL)\u003Cbr>AD 2.5 |\n| --- |\n| Conceptual Design\u003Cbr>• What are the entities and relationships that we want to describe?\u003Cbr>• What information about entities and relationships should we store in the database?\u003Cbr>• What integrity constraints hold?\u003Cbr>• Represent this information pictorially in an E-R diagram, then map this diagram into a relational schema (SQL DDL.)\u003Cbr>AD 2.7 |\n\n\n| ER digarams – the basics\u003Cbr>In ER diagrams we break the world down into three kinds of things:\u003Cbr","cbCailLsDoQBvHCB","https://ap.wps.com/l/cbCailLsDoQBvHCB","pdf",68732,"English","# Key Constraints\n# SQL DDL and Constraints\n## Inclusion Constraints\n# Schema Modification\n# Conceptual Modelling – a Caution\n# Conceptual Modelling and ER Diagrams\n## Conceptual Design\n## ER Diagrams – the Basics\n## Drawing Relationships\n## Drawing Entity Sets\n## The Whole Diagram\n# Obtaining the Relational Schema from an ER Diagram","[{\"question\":\"What is a key constraint and why do updates violate it get rejected?\",\"answer\":\"A key is a subset of attributes that uniquely identifies a tuple. Updates that would break this uniqueness property are rejected to keep the database instance valid.\"},{\"question\":\"How do inclusion constraints work in relational databases?\",\"answer\":\"An inclusion constraint means a field in one table references a tuple in another relation by using its key. The referenced tuple must exist for the database to remain valid.\"},{\"question\":\"What is the purpose of foreign key constraints in the handout’s examples?\",\"answer\":\"Foreign key constraints are a restricted form of inclusion constraints that enforce referential existence. The example ties Climbs to Hikers and Munros through FOREIGN KEY references.\"}]","Applied Databases - Handout 2 - Database Design | PDF",1792966474,18]