• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

learn-co-students/sql-library-lab-v-000

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

learn-co-students/sql-library-lab-v-000

开源软件地址(OpenSource Url):

https://github.com/learn-co-students/sql-library-lab-v-000

开源编程语言(OpenSource Language):

Ruby 90.0%

开源软件介绍(OpenSource Introduction):

SQL Fantasy Library

We're going to build a SQL database that will keep track of books from a fantasy series in a library. These types of books can get complex, with many characters that span many books in a series, or just appear in one book, and characters that are species other than human. We will have tables for: Characters, Books, Series, Authors, and Sub-Genres. For a refresher on SQL syntax as you work through this lab, the W3Schools SQL Tutorial is a helpful reference, as well as the resources listed below.

Objectives

  • Become comfortable writing SQL statements to create tables that have complex relations with each other
  • Understand and implement JOINs to write complex SELECT statements to query a database

Section 1: schema.sql

Build out the schema for our Fantasy Library database:

  1. All tables must have a PRIMARY KEY on the id
  2. The Series table should have a title and belong to an author and a sub-genre
  3. The Sub-Genres table has a name
  4. The Authors table has a name
  5. The Books table has a title and year and belong to a series
  6. The Characters table has a name, motto, and species and belong to an author
  7. The Books table has many characters and characters are in many books in a series. How do we accomplish this complex association? With a join table between Characters and Books. This join table (let's call it character_books) will just have -in addition to its primary key- two foreign key columns for the character and book ids. Each row in this join table acts as a relation between a book and a character.

Section 2: insert.sql

Populate the database with the following:

  • 2 series

  • 2 sub-genres

  • 2 authors

  • 3 books in each series

  • 8 characters

    • 4 characters in each series
      • of each of those 4, make 2 in all of the books in a series, and 2 in just 1 book in a series
  • Note you will need to insert values into your character_books join table

  • Feel free to make these up if you don't know any Fantasy series :)

Section 3: update.sql

Update the species of the last character in the database to "Martian" by writing an update statement in update.sql.

Section 4: Querying your database

In lib/querying.rb, complete the tests by writing the appropriate queries to satisfy the queries. Note that for this section, the database will be seeded with external data so don't expect it to reflect the data you added above.

Resources

View SQL Library Lab on Learn.co and start learning to code for free.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap