Spectrum Same External Table Shows in Multiple Schemas (svv_external_tables) - external-tables

It's a really simple test actually. I create a couple external schemas and create an external table in one of the schemas and then querying svv_external_tables shows the table exists in ALL schemas!! What am I missing?
create external schema mytestschema from data catalog
database 'mytestdb'
iam_role 'arn:aws:iam::123456789:role/spectrumrole'
;
create external table mytestdb.mytestschema.newtable (
col1 varchar(200),
col2 varchar(200),
col3 varchar(200)
)
partitioned by (cycle_date varchar(20) )
stored as parquet
location 's3://s3loc';
select * from svv_external_tables;

External schema doesn't hold the table descriptions, it just hold the connection parameters to a database in data catalog. Or put the other way - whatever is in the data catalog database is shown in every external schema that points to it.

Related

How to use foreign keys in visual studio with data-bound objects

I'm trying to build a program that saves and retrieve's data from multiple tables in an Azure SQL database and most of the MS tutorials are based on data-bound controls.
I have setup the SQL server and added 2 tables, machine_list and customer_list.
machine_list has an id, a machine number and a customer id column. customer_list has a customer id and a customer name column. the machine_list customer id uses a foreign key constraint to connect it with the customer id column in customer_list
In my winform project I have setup the machine_list table as a data source and created the data-bound controls for the machine number column and created a textbox control to be filled in with the customer name column value connected with the machine. However when I try to add the query below:
SELECT machine_list.Id, machine_list.machine_number,
machine_list.customer_id, customer_list.customer_id,
customer_list.customer_name
FROM machine_list INNER JOIN customer_list
ON machine_list.customer_id=customer_list.customer_id
WHERE machine_list.machine_number = #machineNumber
and I get the error
The schema returned by the new query differs from the base query.
I'm not sure if this is the correct method to store and retrieve data this way because I'm using different sources of documentation to learn about it
Also should I be using the customer_list table as a data-source with a customer name bound control in my form instead of a regular TextBox? for displaying the customer name

EF6 Create one way navigation in db with two schemas

We have two tables in the same database but in different schemas.
i.e. foo.Table1 and bar.Table1 both with an Id column as primary key.
foo.Table1 is from an existing model, cannot be modified and is already in the database.
We want to create an ef6 code first model of bar.Table1 that will have its primary key (bar.Table1.Id) set as a foreign key of foo.Table1.Id. We have already accomplished it in SMSS but we cannot figure out how to do it in code without affecting foo.Table1.
Thank you

Wakanda add collection

I have install wakanda and testing in my computer.
Then I testing to create 2 tables named table1 and table2 with structure like this:
table1: ID, Name, table2Collection
table2: ID, Table1, Name
I want to create trigger that when table1 is saved, a new row is also inserted in to table2 and to create relation between table1 and table2.
I try to create event on table1 On Save like this:
var newTable2 = new ds.table2;
newTable2.Name = this.Name;
newTable2.save();
But this code not create relation between table1 and table2.
Can some body help me?
Wakanda is an object database. We don't talk about Tables but about DataClasses.
Here two level of answers for your question:
Triggers: Wakanda as "events" to which you can assign JavaScript functions and one of them is "save". You can fix it via the event tab in the Datastore Model Designer, or directly in JavaScript via the Model API if using free form edition. Events like "on save" exist at the Dataclass and the attribute levels
Relations: Wakanda as "relation attributes". In your example, you are copying a string value. You should better have an entity relation attribute and have code like
var newDataClass2 = new DataClass2();
newDataClass2.dataClass1 = this;
newDataClass2.save();
your Name attribute would be accessible through newDataClass2.dataClass1.Name
or could be available through newDataClass2.dataClass1Name if you add an alias attribute

retrive data using multiple table in core data in iPhone

Actually I have three tables as empName(empId,empName),empSalary(empId,salary),empBonus(salary,bonus).
And I have a name and need to find the bonus.
So My logic is that first find using name I will find the empId then using empId find the salary and finally using salary find the bonus from empBonus table.
How can I achieve following things in core data in iPhone.
Use relationships between data, so that whenever you find the name, it also finds the salary and bonus from the other tables. See here
I would not do raw sqlite queries if you have this level of knowledge of Core Data and Sql.
First of all you should stop thinking in tables. Core Data is not a wrapper for SQlite.
If you want tables don't use Core Data and use SQLite.
Core Data is an object graph and persistence framework. You have entities instead of tables.
Because you are talking about tables I have no idea what you actually want but your Data Model could look like this:
or this:
(the Employee->Salary relationship in the last screenshot should be to-many, I forgot to put that into the model.)
and because you have an object graph you can get all the objects in that graph.
For the last example model your code could look like this:
Employee *myEmployee = /* do a fetch to get an Employee */
NSSet *salaries = myEmployee.salaries;
Salary *salary = /* choose one from the salaries set */
Bonys = salary.bonus;

Setting relations Grocery CRUD

I have 2 tables
Users Table => id , username
OrdersTable => order_id,user_id, qty,total
I need to link these two tables with .
id and user_id.
how can i do this with grocery CRUD.
If you're using OrdersTable as your primary table, you can use a 1:1 relationship using set_relation(). This would be if you were viewing an order and wanted to see/set which user the order belongs to.
$crud->set_table('OrdersTable');
$crud->set_relation('id','UsersTable','username');
This will allow you to select which user for a particular order.
However, presumably a user may have many orders- a 1:n relationship. This would be the case if UsersTable is your primary table, i.e. you're viewing a user in the CRUD and want to see all associated orders.
This method requires an intermediary table, with which you link the two existing tables, and a slight change to your existing table structure. You'd need to remove user_id in the OrdersTable. The intermediary table, for the sake of argument called UserOrdersTable would require the following columns.
user_id INT
order_id INT
priority INT
You can then add the relationship using the set_relation_n_n() method.
You can then reverse the set_relation_n_n() call for when viewing the OrdersTable so you can see which user made an order.
To summarise, a 1:n relationship using set_relation_n_n() will allow you to view orders by a user, and a user for an order.
If you mean query, then;
select u.id, u.username, o.order_id, o.qty, o.total
from users u
left join orders o on(o.user_id = u.id)
where 1=1

Resources