Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Gleb Patsiia
committed
Feb 5, 2024
1 parent
190c57f
commit f0a8877
Showing
5 changed files
with
59 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
CREATE TABLE IF NOT EXISTS account_types ( | ||
type_id INT NOT NULL PRIMARY KEY, | ||
type_name VARCHAR(255) NOT NULL | ||
); | ||
CREATE TABLE IF NOT EXISTS users ( | ||
id INT NOT NULL, | ||
user_id INT NOT NULL PRIMARY KEY, | ||
name VARCHAR(255), | ||
email VARCHAR(255), | ||
account_type_id INT NULL, | ||
FOREIGN KEY (account_type_id) | ||
REFERENCES account_types(type_id) | ||
); | ||
|
||
SELECT | ||
users.name, | ||
users.email, | ||
account_types.type_name FROM users | ||
LEFT JOIN account_types ON users.account_type_id = account_types.type_id; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?xml version="1.0"?> | ||
|
||
<sqlgg> | ||
<stmt name="create_account_types" sql="CREATE TABLE IF NOT EXISTS account_types ( 
 type_id INT NOT NULL PRIMARY KEY, 
 type_name VARCHAR(255) NOT NULL 
)" category="DDL" kind="create" target="account_types" cardinality="0"> | ||
<in/> | ||
<out/> | ||
</stmt> | ||
<stmt name="create_users" sql="CREATE TABLE IF NOT EXISTS users (
 id INT NOT NULL, 
 user_id INT NOT NULL PRIMARY KEY, 
 name VARCHAR(255), 
 email VARCHAR(255), 
 account_type_id INT NULL, 
 FOREIGN KEY (account_type_id) 
 REFERENCES account_types(type_id)
)" category="DDL" kind="create" target="users" cardinality="0"> | ||
<in/> | ||
<out/> | ||
</stmt> | ||
<stmt name="select_2" sql="SELECT 
 users.name,
 users.email, 
 account_types.type_name FROM users 
LEFT JOIN account_types ON users.account_type_id = account_types.type_id" category="DQL" kind="select" cardinality="n"> | ||
<in/> | ||
<out> | ||
<value name="name" type="Text"/> | ||
<value name="email" type="Text"/> | ||
<value name="type_name" type="Text" nullable="true"/> | ||
</out> | ||
</stmt> | ||
<table name="users"> | ||
<schema> | ||
<value name="id" type="Int"/> | ||
<value name="user_id" type="Int"/> | ||
<value name="name" type="Text"/> | ||
<value name="email" type="Text"/> | ||
<value name="account_type_id" type="Int" nullable="true"/> | ||
</schema> | ||
</table> | ||
<table name="account_types"> | ||
<schema> | ||
<value name="type_id" type="Int"/> | ||
<value name="type_name" type="Text"/> | ||
</schema> | ||
</table> | ||
</sqlgg> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters