Saibo Geng
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # CS322 REPORT OF DELIVERABLE ONE #### Part 0: Data Exploration The data given is a subset of the famous Yelp data which consists on the feebacks of clinets on business.The We have 4 csv files: - tip.csv - review.csv - user.csv - business.csv Each of these csv files contains various columns which represent to some extent the attributes or characteristics of the entity. As we only want our attributes values to be atomic, we decide to separate the columns of each csv files into two kinds: atomic, non-atomic. Here we list all fields which are not atomic because they're the more difficult to treat with. - __user.csv__ contains the following non-atomic fileds: - elite - friends - __Business.csv__ contains the following non-atomic fileds: - attributes - categories - hours - __tip.csv__ contains the following non-atomic fields: - Null - __review.csv__ contains the following non-atomic fileds: - Null #### Part 1: ER Diagram An ER diagram should contain entity set, relation set, attributes , and also the link between entity set and relation set. We first consider business, tips, reviews and users as four entities sets and all the atomic fields contained in the corresponding csv file are considered as attributes linked to the entity. As for non-atomic fields, we discuss them one by one: - __elite__ : - a list of years - one user can have many years for elite - represent it by a weak entity set for user - contain each corresponding elite year for each users as separate rows - __friends__: - a list of user_id of friends (we call them invited users of a particular inviting users) - inviting users can have many or no friends, and one user can become invited users of many or no users - represent it by a relation set - contain user_id of both inviting users and invited users - __attributes__: - have 6 catogaries: Music,GoodForMeal,BusinessParking,Ambience,DietaryRestrictions, Noise - all of them (except noise which is atomic) have its own (fixed) set of keys and corresponding atomic values (of boolean) - represent noise as attribute of business - represent others as individual weak entity sets for business, containing their keys as attributes - __categories__: - list of words with over 1000 unique value of words - impossible to have columns for each unique value of words - represent as attribute of business (of long string) - __hours__: - have 7 atomic values (time) for each weekdays - represent by a weak entity sets for business, with each weekdays as attribute ### Constraints: #### Entity set: - user has user_id as __primary key__ - review has review_id as __primary key__ - business has business_id as __primary key__ - tip has no primary key. It's a __weak entity__. It has two owner sets: user and business. __User_id, business_id__ and __tip.date__ all together form a __primary key__ for tip set. - elite is a __weak entity__ whose owner set is user. User_id and elite_year together form a __primary key__ for elite set. - each non-atomic catagory of attributes (Music,GoodForMeal,BusinessParking,Ambience,DietaryRestrictions) are __weak entity__ whose owner set is business. business_id is both the __foreign key__ and __primary key__ - hours is a __weak entity__ whose owner set is business. business_id is both __foreign key__ and __primary key__. | Entity set | Primary Key | Foreign Key | NOT NULL | UNIQUE | | ------------------- | ----------------------------------| ------------------ | ------------------ | ------ | | User | user_id | None | None | None | | Review | review_id | user_id, business_id | user_id, business_id | None | | Business | business_id | None | None | None | | Tip (weak entity) | (user_id, business_id, date) | user_id, business_id | user_id, business_id | None | | Hours(weak entity) | business_id | business_id | business_id | None | | Music(weak entity) | business_id | business_id | business_id | None | | GoodForMeal(weak entity) | business_id | business_id | business_id | None | | BusinessParking(weak entity) | business_id | business_id | business_id | None | | Ambience(weak entity) | business_id | business_id | business_id | None | | DietaryRestrictions(weak entity)| business_id | business_id | business_id | None | | Elite(weak entity) | (user_id,year) | user_id | user_id,year | None | | Relation set | Primary Key | Foreign Key | NOT NULL | UNIQUE | | ------------ | ------------------ | --------------- | --------------- | ------ | | friends | (userID1,userID2 ) | userID1,userID2 | userID1,userID2 | None | ## DDL code ```sql CREATE TABLE Ambiance( CASUCAL BOOLEAN, CLASSY BOOLEAN, DIVEY BOOLEAN, HIPSTER BOOLEAN, INTIMATE BOOLEAN, ROMANTIC BOOLEAN, TOURISTY BOOLEAN, TRENDY BOOLEAN, UPSCALE BOOLEAN, PRIMARY KEY (BUSINESS_ID), FOREIGN KEY (BUSINESS_ID) REFERENCE BUSINESS, ) CREATE TABLE HaveBusinessParking( GARAGE BOOLEAN, LOT BOOLEAN, STREET BOOLEAN, VALET BOOLEAN, VALIDATED BOOLEAN, PRIMARY KEY (BUSINESS_ID), FOREIGN KEY (BUSINESS_ID) REFERENCE BUSINESS, ) CREATE TABLE HaveDietaryRestrictions( DIARY_FREE BOOLEAN, GULTEN_FREE BOOLEAN, HALAL BOOLEAN, KOSHER BOOLEAN, SOY_FREE BOOLEAN, VEGAN BOOLEAN, VEGETARIAN BOOLEAN PRIMARY KEY (BUSINESS_ID), FOREIGN KEY (BUSINESS_ID) REFERENCE BUSINESS, ) CREATE TABLE HaveGoodForMeal( BREAKFAST BOOLEAN, BRUNCH BOOLEAN, DESSERT BOOLEAN, DINNER BOOLEAN, LATENIGHT BOOLEAN, LUNCH BOOLEAN, PRIMARY KEY (BUSINESS_ID), FOREIGN KEY (BUSINESS_ID) REFERENCE BUSINESS, ) CREATE TABLE HaveMusic( BACKGROUND_MUSIC BOOLEAN, DJ BOOLEAN, JUKEBOX BOOLEAN, KARAOKE BOOLEAN, LIVE BOOLEAN, NO_MUSIC BOOLEAN, VIDEO BOOLEAN, BUSINESS_ID CHAR [22] PRIMARY KEY (BUSINESS_ID), FOREIGN KEY (BUSINESS_ID) REFERENCE BUSINESS, ) CREATE TABLE Open_in_Hours( MONDAY CHAR[11], # e.g. 8:00-19:00 TUESDAY CHAR[11] WEDNESDAY CHAR[11] THURSDAY CHAR[11] FRIDAY CHAR[11] SATURDAY CHAR[11] SUNDAY CHAR[11] PRIMARY KEY (BUSINESS_ID), FOREIGN KEY (BUSINESS_ID) REFERENCE BUSINESS, ) CREATE TABLE BUSINESS( BUSINESS_ID CHAR [22] POSTE_CODE VARCHAR[16] # max poste code lenth in data=8 ADDRESS VARCHAR[128] # max address lenth in data=118 CITY VARCHAR[64] # max name lenth in data =50 LATITUDE FLOAT, LONGITUDE FLOAT, IS_OPEN BOOLEAN, NAME VARCHAR(128), #MAX IN DATA =64 REVIEW_COUNT INT. STARS INT, STATE CHAR[2], # AZ,ON... NOISE_LEVEL CHAR [10],#{'None', 'average', 'loud', 'quiet', 'very_loud'} CATEGORIES TEXT, # max of lenth of categories in data =550 ) CREATE TABLE YELP_USER ( average_stars FLOAT, compliment_cool INTEGER, compliment_cute INTEGER, compliment_funny INTEGER, compliment_hot INTEGER, compliment_list INTEGER, compliment_more INTEGER, compliment_note INTEGER, compliment_photos INTEGER, compliment_plain INTEGER, compliment_profile INTEGER, compliment_writer INTEGER, cool INTEGER, fans INTEGER, funny INTEGER, name varchar(64), review_count INTEGER, useful INTEGER, user_id char(22), yelping_since DATETIME, PRIMARY KEY (user_id) ); CREATE TABLE ELITE( awardee char(22), year INTEGER, PRIMARY KEY (awardee,year), FOREIGN KEY (awardee) REFERENCES YELP_USER(user_id) ) CREATE TABLE FRIENDS( inviting char(22), invited char(22), PRIMARY KEY (inviting,invited), FOREIGN KEY (inviting) REFERENCES YELP_USER(user_id), FOREIGN KEY (invited) REFERENCES YELP_USER(user_id) ) create table TIP ( business_id char(22), compliment_count INTEGER, date DATETIME, text varchar(1024), user_id char(22), PRIMARY key (business_id,date,user_id), FOREIGN KEY (business_id) REFERENCES BUSINESS(business_id), FOREIGN KEY (user_id) REFERENCES YELP_USER(user_id), ); create TABLE REVIEW( business_id char(22), cool INTEGER, date DATETIME, funny FLOAT, review_id char(22), stars FLOAT, text varchar(1024), useful FLOAT, user_id char(22), PRIMARY key (review_id), FOREIGN KEY (business_id) REFERENCES BUSINESS(business_id), FOREIGN KEY (user_id) REFERENCES YELP_USER(user_id), ) ```

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully