[ Prev ]
2021-03-17

-- Mar 17 In-Class Exercise
USERS(USERID, USERNAME, EMAIL, PASSWORD) POST(POSTID, USERID, POST, POPULARITY) USERID → USERNAME, EMAIL, PASSWORD POSTID → USERID, POST, POPULARITY Yes this is BNCF
USERS(USERID, USERNAME, EMAIL, PASSWORD) POST(POSTID, USERID, POST, POPULARITY) USERID → USERNAME, EMAIL, PASSWORD POSTID → USERID, POST, POPULARITY Yes this is BNCF

-- Mar 17 In-Class Exercise
CREATE TABLE Users (
	uid INT PRIMARY KEY,
	fname STRING,
	lname STRING
)
CREATE TABLE Posts (
	pid INT PRIMARY KEY,
	uid INT REFERENCES Users(uid),
	content STRING,
	popularity INT,
	timestamp DATE
)

Functional Dependencies:
Users
uid → (fname, lname)
Posts
pid → (uid, content, popularity, timestamp)

Is this in BCNF?
Yes, because the left side of each FD is a key for the table.(Edited: 2021-03-17)
<pre> CREATE TABLE Users ( uid INT PRIMARY KEY, fname STRING, lname STRING ) </pre> <pre> CREATE TABLE Posts ( pid INT PRIMARY KEY, uid INT REFERENCES Users(uid), content STRING, popularity INT, timestamp DATE ) </pre> <br><br> Functional Dependencies:<br> Users<br> uid → (fname, lname) <br> Posts<br> pid → (uid, content, popularity, timestamp) <br><br> Is this in BCNF? <br> Yes, because the left side of each FD is a key for the table.

-- Mar 17 In-Class Exercise
users(user number, username, password)
posts(post number, username, content, popularity)
user number -> username, password
post number -> username, content, popularity
(Edited: 2021-03-17)
users(user number, username, password) posts(post number, username, content, popularity) user number -> username, password post number -> username, content, popularity

-- Mar 17 In-Class Exercise
USER(USERNAME, EMAIL, PASSWORD), POST(POST_ID, CONTENT, POPULARITY), POSTED_BY(USERNAME, POST_ID)
EMAIL --> USERNAME PASSWORD --> USERNAME CONTENT --> POST_ID POPULARITY --> POST_ID POST_ID --> USERNAME
USER(USERNAME, EMAIL, PASSWORD), POST(POST_ID, CONTENT, POPULARITY), POSTED_BY(USERNAME, POST_ID) EMAIL --> USERNAME PASSWORD --> USERNAME CONTENT --> POST_ID POPULARITY --> POST_ID POST_ID --> USERNAME

-- Mar 17 In-Class Exercise
Create TABLE users (user_id integer, l_name varchar(30) not null, f_name varchar(30) not null, post varchar(255)); Create Table posts(post_id integer, thumbsup integer not null)
post_id --> thumbsup, post, post_id user_id --> f_name, l_name, user_id It could be BCNF.
(Edited: 2021-03-17)
Create TABLE users (user_id integer, l_name varchar(30) not null, f_name varchar(30) not null, post varchar(255)); Create Table posts(post_id integer, thumbsup integer not null) post_id --> thumbsup, post, post_id user_id --> f_name, l_name, user_id It could be BCNF.

-- Mar 17 In-Class Exercise
 USER(UNAME, EMAIL, POST_ID)
 POST_ID(POST_DATE, POST_DATA, POPULARITY)
 UNAME, EMAIL--> POST_ID
 UNAME--> EMAIL
 POST_ID--> UNAME, EMAIL
 POST_ID--> POST_DATE, POST_DATA, POPULARITY
 Tables are in BCNF because all non-trivial FD fix all rows. 
(Edited: 2021-03-17)
USER(UNAME, EMAIL, POST_ID) POST_ID(POST_DATE, POST_DATA, POPULARITY) UNAME, EMAIL--> POST_ID UNAME--> EMAIL POST_ID--> UNAME, EMAIL POST_ID--> POST_DATE, POST_DATA, POPULARITY Tables are in BCNF because all non-trivial FD fix all rows.

-- Mar 17 In-Class Exercise
users(user_id(int), username(string), password_hash(string)) posts(post_id(int), user_id(int), content(string), upvotes(int)) user_id --> username, password_hash post_id --> user_id, content, likes Tables are in BCNF because all non-trivial functional dependencies fix all rows for each table
(Edited: 2021-03-17)
<nowiki> users(user_id(int), username(string), password_hash(string)) posts(post_id(int), user_id(int), content(string), upvotes(int)) user_id --> username, password_hash post_id --> user_id, content, likes Tables are in BCNF because all non-trivial functional dependencies fix all rows for each table </nowiki>

-- Mar 17 In-Class Exercise
USER(UID, USERNAME, PASSWORD) POST(PID, UID, POST_TEXT, THUMBSUP) UID → USERNAME, PASSWORD PID → USERID, POST_TEXT, THUMBSUP
USER(UID, USERNAME, PASSWORD) POST(PID, UID, POST_TEXT, THUMBSUP) UID → USERNAME, PASSWORD PID → USERID, POST_TEXT, THUMBSUP

-- Mar 17 In-Class Exercise

------TABLES---------- USERID = string USERNAME = string EMAIL = string PASSWORD = string POSTID = int TEXT = string POPULARITY = int    USER(USERID, USERNAME, EMAIL, PASSWORD) POSTS(USERID, POSTID, TEXT, POPULARITY)    ---FUNCTIONAL DEPENDENCIES---------- USERID --> USERNAME, PASSWORD, EMAIL POSTID --> USERID, TEXT, POPULARITY
(Edited: 2021-03-17)
<pre> ----------TABLES---------- USERID = string USERNAME = string EMAIL = string PASSWORD = string POSTID = int TEXT = string POPULARITY = int USER(USERID, USERNAME, EMAIL, PASSWORD) POSTS(USERID, POSTID, TEXT, POPULARITY) ---FUNCTIONAL DEPENDENCIES---------- USERID --> USERNAME, PASSWORD, EMAIL POSTID --> USERID, TEXT, POPULARITY </pre>

-- Mar 17 In-Class Exercise
User(user_id, username, password, email) with primary key is user_id
Post(post_id, post_content, likes, user_id) with primary key is post_id
user_id --> username, password, email
post_id --> post_content, likes, user_id
These tables are in BCNF because they don't cause any redundancy
(Edited: 2021-03-17)
User(user_id, username, password, email) with primary key is user_id Post(post_id, post_content, likes, user_id) with primary key is post_id user_id --> username, password, email post_id --> post_content, likes, user_id These tables are in BCNF because they don't cause any redundancy
[ Next ]
X